|
Message-ID: <20180205172714.GY1627@brightrain.aerifal.cx> Date: Mon, 5 Feb 2018 12:27:14 -0500 From: Rich Felker <dalias@...c.org> To: musl@...ts.openwall.com Subject: Re: [PATCH] re-fix child reaping in wordexp On Mon, Feb 05, 2018 at 08:07:44PM +0300, Alexander Monakov wrote: > On Mon, 5 Feb 2018, Rich Felker wrote: > > > In general retrying waitpid on EINTR is not robust in case pid reuse is > > > possible, but fixing that requires changing waitpid call sites to only > > > do that with signals blocked (where that's not already the case). > > > > I don't follow this. Unless there's a bug in the kernel, this should > > not be functionally different from SA_RESTART. A return with EINTR > > means the child was not reaped. > > The problem I had in mind is that you don't know if a signal handler or > another thread had (yes, incorrectly) already reaped that child when you > are about to retry waitpid. > > With signals blocked, you issue just one waitpid, and you need very rapid > pid reuse to happen, after someone successfully reaps your child > even before you enter waitpid. > > Of course this is a bit moot since the other thread/sighandler shouldn't > be issuing wildcard waits in the first place, and if rapid pid reuse > does not happen you safely leave the retry loop with ECHILD. But this is > why I said "not robust" rather than "incorrect". OK, that makes sense -- it's a matter of tiny window vs unboundedly-large window. And in this case EINTR is not relevant; the same unboundedly-large window can happen if you have a long-running signal handler with SA_RESTART. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.