Cancellation & async signal handlers

Scott Lamb slamb@slamb.org
Thu Feb 5 19:32:00 GMT 2004


I've got another question about thread cancellation. First, am I in the 
right place for this? This is like my third message about cancellation 
and I haven't seen much in the way of replies.

Okay, my question: what should happen if you receive a cancellation 
request in a cancellation point (specifically write()) that is called 
from an async signal handler? The standards do not seem too clear on 
this point. I'd be happy just disabling cancellation for the duration of 
the signal handler, but pthread_setcancelstate() is not marked as async 
signal-safe.

I wrote a test program, and glibc appears to occasionally hang. Is this 
a bug? Did I screw up the test (quite possible)? Or is this just 
undefined behavior? And if there is undefined behavior, I'd greatly 
appreciate any suggestions for an alternate way of waiting for any one of:

- IO events
- signals
- cancellation requests

pselect() seems good in concept but the Linux implementation contains a 
race, as noted in the manual page. Besides, there is no pepoll(). And 
there's no kqueue on Linux, so I don't see any alternative.

Thanks,
Scott Lamb



More information about the Libc-alpha mailing list