Skip to content

Instantly share code, notes, and snippets.

@ajorg
Created August 24, 2010 15:14
Show Gist options
  • Save ajorg/547712 to your computer and use it in GitHub Desktop.
Save ajorg/547712 to your computer and use it in GitHub Desktop.
diff --git a/MonkeyWrench/ProcessHelperLinux.cs b/MonkeyWrench/ProcessHelperLinux.cs
index 9707d0f..380e533 100755
--- a/MonkeyWrench/ProcessHelperLinux.cs
+++ b/MonkeyWrench/ProcessHelperLinux.cs
@@ -50,6 +50,18 @@ namespace MonkeyWrench
/// <param name="pids"></param>
internal static void KillImpl (IEnumerable<int> pids)
{
+ using (Process quit = new Process ()) {
+ quit.StartInfo.FileName = "kill";
+ quit.StartInfo.Arguments = "-QUIT ";
+ foreach (int pid in pids) {
+ quit.StartInfo.Arguments += pid.ToString () + " ";
+ }
+ quit.StartInfo.UseShellExecute = false;
+ quit.Start ();
+
+ if (!quit.WaitForExit (1000 * 15 /* 15 seconds */))
+ throw new ApplicationException (string.Format ("The 'kill -QUIT' process didn't exit in 15 seconds."));
+ }
using (Process kill = new Process ()) {
kill.StartInfo.FileName = "kill";
kill.StartInfo.Arguments = "-9 ";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment