This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] test-skeleton: Kill any child process's offspring
- From: Roland McGrath <roland at hack dot frob dot com>
- To: "Maciej W. Rozycki" <macro at codesourcery dot com>
- Cc: <libc-alpha at sourceware dot org>, Ondřej Bílka <neleai at seznam dot cz>
- Date: Mon, 23 Jun 2014 10:34:27 -0700 (PDT)
- Subject: Re: [PATCH v2] test-skeleton: Kill any child process's offspring
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 1 dot 10 dot 1309231748080 dot 4379 at tp dot orcam dot me dot uk> <20131011163332 dot GA20086 at domone dot podge> <20140210171709 dot GA27843 at domone> <alpine dot DEB dot 1 dot 10 dot 1406230100010 dot 25395 at tp dot orcam dot me dot uk>
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