diff options
Diffstat (limited to 'cpp/src/IcePack/ActivatorI.cpp')
-rw-r--r-- | cpp/src/IcePack/ActivatorI.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cpp/src/IcePack/ActivatorI.cpp b/cpp/src/IcePack/ActivatorI.cpp index 807dd2e5c10..e9a992566c2 100644 --- a/cpp/src/IcePack/ActivatorI.cpp +++ b/cpp/src/IcePack/ActivatorI.cpp @@ -227,6 +227,13 @@ IcePack::ActivatorI::activate(const ServerPtr& server) } if(pid == 0) // Child process. { + +#ifdef __linux + // Create a process group for this child, to be able to send + // a signal to all the thread-processes with killpg + // + setpgrp(); +#endif // // Close all file descriptors, except for standard input, // standard output, standard error output, and the write side @@ -365,7 +372,13 @@ IcePack::ActivatorI::deactivate(const ServerPtr& server) // // Send a SIGTERM to the process. // + +#ifdef __linux + // Use process groups on Linux instead of processes + int ret = ::killpg(static_cast<pid_t>(pid), SIGTERM); +#else int ret = ::kill(static_cast<pid_t>(pid), SIGTERM); +#endif if(ret != 0 && getSystemErrno() != ESRCH) { SyscallException ex(__FILE__, __LINE__); @@ -396,7 +409,12 @@ IcePack::ActivatorI::kill(const ServerPtr& server) // // Send a SIGKILL to the process. // +#ifdef __linux + // Use process groups on Linux instead of processes + int ret = ::killpg(static_cast<pid_t>(pid), SIGKILL); +#else int ret = ::kill(static_cast<pid_t>(pid), SIGKILL); +#endif if(ret != 0 && getSystemErrno() != ESRCH) { SyscallException ex(__FILE__, __LINE__); |