[PATCH] test-skeleton: Kill any child process's offspring

Maciej W. Rozycki macro@codesourcery.com
Tue Sep 24 22:09:00 GMT 2013


On Tue, 24 Sep 2013, Roland McGrath wrote:

> That seems reasonable.  But if you do that, then you need to check the
> setpgid call for errors so we never kill the pgrp if it's not a fresh one.

 Hmm, is setpgid (0, 0) allowed to ever fail (other than after setsid has 
been already called, in which case the pgid will be the same as pid 
anyway, and which test-skeleton doesn't do anyway)?  From the way the 
process group API has been defined I infer it cannot, however if I am 
wrong for any reason, then I'll be happy to get enlightened.  Also the 
comment at the setpgid call we have in test-skeleton indicates we already 
rely on the call to always succeed.

 Please also note that fork(2) is not allowed to use a pid for the newly 
created process that is the same as an existing pgid, which means that if 
we use a pid returned from fork(2) as a pgid, then we'll never hit another 
process group even if setpgid should fail for any reason.

 Therefore I think any extra error handling for setpgid here would be a 
case of over-engineering and would only obfuscate code unnecessarily (just 
as would for example checking the return value from execve(2)).

  Maciej



More information about the Libc-alpha mailing list