summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-05-19 10:53:51 -0400
committerBrad King <brad.king@kitware.com>2014-05-20 09:48:35 -0400
commit0c7f84ca41ebd871615426b9a159922422701859 (patch)
treea73bbc5ed7635ab34d02794b2fadb30cefa862b2
parente604209cb930c5bc7e53f58625407b82e6899d0f (diff)
downloadcmake-0c7f84ca41ebd871615426b9a159922422701859.tar.gz
KWSys Process: Workaround child kill trouble on Cygwin
When we kill a child we send SIGSTOP first so that we can traverse its child processes recursively. On unwinding the recursion we then send SIGKILL. Current Cygwin has trouble when both signals are sent in quick succession by the parent process. Add a usleep(1) after sending the first signal to give up our time slice and give Cygwin a chance to process the first signal before sending the second.
-rw-r--r--Source/kwsys/ProcessUNIX.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index faeb967936..241e295738 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -2413,6 +2413,12 @@ static void kwsysProcessKill(pid_t process_id)
/* Suspend the process to be sure it will not create more children. */
kill(process_id, SIGSTOP);
+#if defined(__CYGWIN__)
+ /* Some Cygwin versions seem to need help here. Give up our time slice
+ so that the child can process SIGSTOP before we send SIGKILL. */
+ usleep(1);
+#endif
+
/* Kill all children if we can find them. */
#if defined(__linux__) || defined(__CYGWIN__)
/* First try using the /proc filesystem. */