Re: [PATCH] forstdin: Fix possible error/hanging w/ -p

From: Laurent Bercot <ska-skaware_at_skarnet.org>
Date: Tue, 09 Jun 2015 22:11:53 +0200

On 09/06/2015 20:17, Olivier Brunel wrote:
> + if (pids.s) sig_block(SIGCHLD) ;
> (...)
> + sig_unblock(SIGCHLD) ;

  Gah. Of course that's it - the noob mistake of looping around fork() without
blocking SIGCHLD. That's so, so bad - I'm really ashamed. :(

  That's what happens when you rely on selfpipes all the time: you forget how
to properly deal with signals without them!

  I did some tests after changing the final waiting logic to sig_pause(), and
didn't get any errors, so I figured it was good - but it obviously wasn't.

  Thanks for the report and the fix! Applied in current git, new release soonish.

  I'll still keep the sig_pause() part: it's actually more ad-hoc work to remove
the signal handler and enter a blocking wait() loop than to simply let the signal
handler do its job until there's nothing left. I find the latter more elegant,
even if it didn't work as a fix for the race condition.

-- 
  Laurent
Received on Tue Jun 09 2015 - 20:11:53 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC