Message ID | alpine.DEB.1.10.1406230100010.25395@tp.orcam.me.uk |
---|---|
State | Superseded |
Headers | show |
I don't know what you did to test that change. I can't see how it could possibly work as intended. You've changed the value of PID in the child, but it's only actually used in the parent (where it won't have changed). Am I missing something? Without more futzing than is worthwhile, there is no way that the child can communicate back to the parent whether setpgid succeeded or failed. The error message is nice to have, but I don't think the parent actually needs to care whether setpgid worked or not. If it didn't, there won't be any pgrp with pgid -pid. So I think all you really need is to make the handler do: assert (pid > 1); /* Kill the whole process group. */ kill (-pid, SIGKILL); /* In case, setpgid failed in the child, kill it individually too. */ kill (pid, SIGKILL); Thanks, Roland
Index: glibc-fsf-trunk-quilt/test-skeleton.c =================================================================== --- glibc-fsf-trunk-quilt.orig/test-skeleton.c 2014-06-17 16:03:16.621929397 +0100 +++ glibc-fsf-trunk-quilt/test-skeleton.c 2014-06-21 00:03:23.141622346 +0100 @@ -138,8 +138,9 @@ signal_handler (int sig __attribute__ (( int killed; int status; - /* Send signal. */ + /* Send signal. Undo any PID negation made after setpgid. */ kill (pid, SIGKILL); + pid = abs (pid); /* Wait for it to terminate. */ int i; @@ -341,8 +342,14 @@ main (int argc, char *argv[]) #endif /* We put the test process in its own pgrp so that if it bogusly - generates any job control signals, they won't hit the whole build. */ - setpgid (0, 0); + generates any job control signals, they won't hit the whole build. + Negate the PID if successful so that kill targets the PGID, to + reach any child process's offspring. */ + status = setpgid (0, 0); + if (status == 0) + pid = -pid; + else + printf ("Failed to set the process group ID: %m\n"); /* Execute the test function and exit with the return value. */ exit (TEST_FUNCTION);