From efbfed44b221cd5f41cc62dacb78a0f1b6eede02 Mon Sep 17 00:00:00 2001 From: "K. Noel Belcourt" Date: Mon, 24 Sep 2007 21:01:45 +0000 Subject: [PATCH] Fix a problem with the -lx timeout code on ppc darwin. The intel based darwin system was killing subprocesses okay but for some reason, ppc systems were not. This change fixes the timeout code so subprocesses are properly killed on ppc darwin systems. [SVN r39514] --- historic/jam/src/execunix.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/historic/jam/src/execunix.c b/historic/jam/src/execunix.c index fc95b859c..201698a1f 100644 --- a/historic/jam/src/execunix.c +++ b/historic/jam/src/execunix.c @@ -212,16 +212,15 @@ execcmd( else dup2(err[1], STDERR_FILENO); - /* Make this process a session leader + /* Make this process a process group leader * so that when we kill it, all child * processes of this process are terminated * as well. * - * we use kill(-pid, SIGKILL) to kill the - * session leader and all children of this - * session. + * we use killpg(pid, SIGKILL) to kill the + * process group leader and all its children. */ - setsid(); + setpgid(cmdtab[slot].pid, cmdtab[slot].pid); execvp( argv[0], argv ); _exit(127); @@ -379,7 +378,7 @@ void populate_file_descriptors(int *fmax, fd_set *fds) struct tms buf; clock_t current = times(&buf); if (globs.timeout <= (current-cmdtab[i].start_time)/tps) { - kill(-cmdtab[i].pid, SIGKILL); + killpg(cmdtab[i].pid, SIGKILL); cmdtab[i].exit_reason = EXIT_TIMEOUT; } } @@ -418,7 +417,7 @@ execwait() tv.tv_sec = globs.timeout; tv.tv_usec = 0; - /* select will wait until io on a descriptor or a signal */ + /* select will wait until: io on a descriptor, a signal, or we time out */ ret = select(fd_max+1, &fds, 0, 0, &tv); } else {