If getpgrp() fails, it will return -1 and that will send KILL signal to init
process (PID 1). This does not happen on RHEL, but does on AIX.
Reported-by: Chris Cowan <cc@us.ibm.com>
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
*/
static void sigterm(int sig)
{
+ pid_t pid;
+
/* all the child processes will be running in the same process group */
- kill(-getpgrp(), SIGKILL);
+ pid = getpgrp();
+ if (pid == -1) {
+ kill(-getpid(), SIGKILL);
+ } else {
+ kill(-pid, SIGKILL);
+ }
_exit(1);
}