LWN.net Logo

The race still occurs :-(

The race still occurs :-(

Posted Jul 21, 2008 14:23 UTC (Mon) by almorozov (guest, #53014)
Parent article: The new pselect() system call

Hi
I have just encountered the race condition which the provided recipe tries 
to avoid :-(. The code looks similar to one in the article:

1. SIGCHLD is blocked
2. Then two child processes are invoked (in a "pipe" i.e. output of one 
process 
is the input of another).
3. A SIGCHLD handler similar to one described in 
info '(libc)Merged Signals' is installed

4. So far so good. Then I start to wait in pselect

Logs show that the first child exits, its termination signal is caught by 
the handler and pselect returns with exitcode=-1, errno=EINTR. Ok.

The code performs all necessary actions and returns back to 
pselect(). But when the second child exits there's a *possibility* that 
pselect won't return after signal is caught and processed in the handler.

I put a simple check that right before pselect() SIGCHLD is blocked 
(and it is). Logs show that the handler is invoked (that is the signal was 
unblocked in pselect) but strace'ing the process shows that it's hanging 
on select() :-(. It seems I missed some magic :-(.

Debian-4.0 under VZ-enabled 2.6.18 kernel.


(Log in to post comments)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds