summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/ProcessUNIX.c
diff options
context:
space:
mode:
Diffstat (limited to 'Source/kwsys/ProcessUNIX.c')
-rw-r--r--Source/kwsys/ProcessUNIX.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index e2935eb..2deb2f4 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -2392,13 +2392,8 @@ static void kwsysProcessKill(pid_t process_id)
DIR* procdir;
#endif
- /* Kill the process now to make sure it does not create more
- children. Do not reap it yet so we can identify its existing
- children. There is a small race condition here. If the child
- forks after we begin looking for children below but before it
- receives this kill signal we might miss a child. Also we might
- not be able to catch up to a fork bomb. */
- kill(process_id, SIGKILL);
+ /* Suspend the process to be sure it will not create more children. */
+ kill(process_id, SIGSTOP);
/* Kill all children if we can find them. */
#if defined(__linux__) || defined(__CYGWIN__)
@@ -2486,6 +2481,19 @@ static void kwsysProcessKill(pid_t process_id)
}
#endif
}
+
+ /* Kill the process. */
+ kill(process_id, SIGKILL);
+
+#if defined(__APPLE__)
+ /* On OS X 10.3 the above SIGSTOP occasionally prevents the SIGKILL
+ from working. Just in case, we resume the child and kill it
+ again. There is a small race condition in this obscure case. If
+ the child manages to fork again between these two signals, we
+ will not catch its children. */
+ kill(process_id, SIGCONT);
+ kill(process_id, SIGKILL);
+#endif
}
/*--------------------------------------------------------------------------*/