diff --git a/resources/Defaults.plist b/resources/Defaults.plist
index ac752ad..8eb83ce 100644
--- a/resources/Defaults.plist
+++ b/resources/Defaults.plist
@@ -46,5 +46,7 @@
Any
showPathBar
+ alwaysUseSigkill
+
diff --git a/resources/MainMenu.xib b/resources/MainMenu.xib
index d34d235..472b5cd 100644
--- a/resources/MainMenu.xib
+++ b/resources/MainMenu.xib
@@ -1049,6 +1049,9 @@ DQ
+
+
+
diff --git a/resources/Prefs.xib b/resources/Prefs.xib
index 74a71f0..e802eb0 100644
--- a/resources/Prefs.xib
+++ b/resources/Prefs.xib
@@ -20,35 +20,24 @@
-
+
-
+
-
-
+
-
+
+
-
+
-
+
@@ -168,7 +168,7 @@
-
+
@@ -207,6 +207,17 @@ CA
+
diff --git a/source/PrefsController.m b/source/PrefsController.m
index f78641c..05c90b9 100644
--- a/source/PrefsController.m
+++ b/source/PrefsController.m
@@ -84,6 +84,8 @@ - (IBAction)restoreDefaults:(id)sender {
[DEFAULTS setBool:NO forKey:@"showCurrentWorkingDirectories"];
[DEFAULTS setBool:YES forKey:@"friendlyProcessNames"];
[DEFAULTS setBool:NO forKey:@"authenticateOnLaunch"];
+ [DEFAULTS setBool:NO forKey:@"alwaysUseSigkill"];
+
[DEFAULTS setObject:@[@[@NO, DEFAULT_FILTER]] forKey:@"filters"];
[DEFAULTS synchronize];
diff --git a/source/SlothController.m b/source/SlothController.m
index cb0dd5b..1f1eb2b 100644
--- a/source/SlothController.m
+++ b/source/SlothController.m
@@ -647,17 +647,23 @@ - (IBAction)kill:(id)sender {
// Confirm
BOOL optionKeyDown = (([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) == NSAlternateKeyMask);
+ BOOL ctrlKeyDown = (([[NSApp currentEvent] modifierFlags] & NSControlKeyMask) == NSControlKeyMask);
+ BOOL useSigKill = (ctrlKeyDown || [DEFAULTS boolForKey:@"alwaysUseSigkill"]);
if (optionKeyDown == NO) {
- if ([Alerts proceedAlert:[NSString stringWithFormat:@"Are you sure you want to kill “%@” (%d)?", item[@"pname"], pid]
- subText:@"This will send the process a SIGKILL signal. Hold the option key (⌥) to avoid this prompt."
- withActionNamed:@"Kill"] == NO) {
+ NSString *p = [NSString stringWithFormat:@"Are you sure you want to kill “%@” (%d)?", item[@"pname"], pid];
+ NSString *s = @"This will send the process a SIGTERM signal. Hold the down option key (⌥) to avoid this prompt. Hold down the Control key if you want to send a SIGKILL signal.";
+ if (useSigKill) {
+ s = @"This will send the process a SIGKILL signal. Hold the down option key (⌥) to avoid this prompt.";
+ }
+ if ([Alerts proceedAlert:p subText:s withActionNamed:@"Kill"] == NO) {
return;
}
}
// Kill it
BOOL ownsProcess = [ProcessUtils isProcessOwnedByCurrentUser:pid];
- if ([ProcessUtils killProcess:pid asRoot:!ownsProcess] == NO) {
+ BOOL killSuccess = [ProcessUtils killProcess:pid asRoot:!ownsProcess usingSIGKILL:useSigKill];
+ if (killSuccess == NO) {
[Alerts alert:@"Failed to kill process"
subTextFormat:@"Could not kill process %@ (PID: %d)", item[@"pname"], pid];
return;
@@ -1100,6 +1106,22 @@ - (void)showPathControl {
[v setFrame:r];
}
+- (BOOL)pathControl:(NSPathControl *)pathControl shouldDragItem:(NSPathControlItem *)pathItem withPasteboard:(NSPasteboard *)pboard {
+ NSString *draggedFile = [[pathItem URL] path];
+ [self copyFiles:@[draggedFile] toPasteboard:pboard];
+ return YES;
+}
+
+- (void)copyFiles:(NSArray *)files toPasteboard:(NSPasteboard *)pboard {
+ [pboard clearContents];
+ [pboard declareTypes:@[NSFilenamesPboardType] owner:nil];
+ [pboard setPropertyList:files forType:NSFilenamesPboardType];
+
+ NSString *strRep = [files componentsJoinedByString:@"\n"];
+ [pboard setString:strRep forType:NSStringPboardType];
+}
+
+
#pragma mark - Menus
- (void)menuWillOpen:(NSMenu *)menu {
diff --git a/source/Util/ProcessUtils.h b/source/Util/ProcessUtils.h
index 4e70de1..2f39dd3 100644
--- a/source/Util/ProcessUtils.h
+++ b/source/Util/ProcessUtils.h
@@ -44,6 +44,8 @@
+ (NSString *)procNameForPID:(pid_t)pid;
+ (NSString *)fullKernelProcessNameForPID:(pid_t)pid;
+ (NSString *)executablePathForPID:(pid_t)pid;
-+ (BOOL)killProcess:(int)pid asRoot:(BOOL)asRoot;
++ (BOOL)killProcess:(int)pid
+ asRoot:(BOOL)asRoot
+ usingSIGKILL:(BOOL)useSigkill;
@end
diff --git a/source/Util/ProcessUtils.m b/source/Util/ProcessUtils.m
index 6c86a2b..378b202 100644
--- a/source/Util/ProcessUtils.m
+++ b/source/Util/ProcessUtils.m
@@ -208,9 +208,10 @@ + (NSString *)executablePathForPID:(pid_t)pid {
return path;
}
-+ (BOOL)killProcess:(int)pid asRoot:(BOOL)asRoot {
++ (BOOL)killProcess:(int)pid asRoot:(BOOL)asRoot usingSIGKILL:(BOOL)useSigkill {
+ int signal = useSigkill ? SIGKILL : SIGTERM;
if (!asRoot) {
- return (kill(pid, SIGKILL) == 0);
+ return (kill(pid, signal) == 0);
}
// Kill process as root