sem_wait frequently returning with EINTR [Was: Re: How to "bisect" Cygwin?]

Otto Meta
Fri Jun 1 22:08:00 GMT 2012

> The basic issue is that sem_wait() is being kicked out with EINTR
> extremely frequently (9 out of 10 times or more), which slows my code
> to a crawl as it repeatedly retries sem_wait() until it finally
> returns zero.  In 1.7.9, it does not appear that sem_wait() is
> preempted in this fashion; the thread would simply wait on the
> semaphore until it was sem_post()'d and then continue as expected.

Are you using signals or functions that use signals internally? Signals are
a bit wonky in 1.7.9 and they seem to be pretty much broken in 1.7.12 and
newer (I didn’t try any snapshots). Have a look at the problem I reported:
While the cancelling part seems to be mostly fixed by now, the signal part
is still unchanged.

Maybe you could try test 3 from my test program attached to the above
mentioned post. If its output changes along with your program’s behaviour
when you try different Cygwin versions, your problem could be signal-related.

Warren Young wrote in
> You should just get an infinite series of "Child timed out normally waiting
> for the semaphore." messages from it after initialization, one per second.

This works for me out of the box, but if I create one or more pthreads before
the alarm loop it just fails: Some other thread gets woken up and the main
thread stays stuck in sem_wait.

If Ryan had told us more about his program, we’d know whether he uses multiple
threads or multiple processes...


Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list