I think the proper fix is to use sigprocmask() disable signals, then rather than using select(), call pselect() which takes a signal mask and will atomically use that mask during the select. This should fix the race condition and force signals to be processed simultaneously to file descriptors.
On Jan 24, 2008 5:03 AM, Lars Munch <[EMAIL PROTECTED]> wrote: > Hi > > While working on suspend/resume on my embedded system I ran into to the > race problem between select and signals. See this link for a description > of the problem: > > http://www.xs4all.nl/~evbergen/unix-signals.html > > The problem is that the following code in ecore_main_select is not an > atomic operation and could end up in select waiting forever even though > there is a signal to be served and put in the event queue: > > if (_ecore_signal_count_get()) return -1; > ret = select(max_fd + 1, &rfds, &wfds, &exfds, t); > > My proposed solution (see attached patch) is something similar to that > described in above link, namely to create a pipe to flag a signal > arrival to select. NOTE: the attached patch currently only handles > sigusr1 and sigusr2 and has almost no error checking. > > As far as I can tell, the attached patch still have a race around > sig_count and sigXXX_count. I thought about adding the signal number to > the signal pipe to avoid this race, but that solution could result in > pipe buffer overflow and then signals would get lost. > > Before I continue working on this patch, I really like your comments and > suggestions. > > Thanks > > -- Lars Munch > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > enlightenment-devel mailing list > enlightenment-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel