> I'm writing a multithreaded program where I want only the main thread to
> perform an action when it receives a SIGINT. I set my signal handler in the
> main thread, and used pthread_sigmask(SIG_BLOCK, SIGINT, NULL) in my other
> In my main thread, I installed the signal handler function with signal(), but
> I see there is a function called sigaction() as well. The latter seems to be
> more POSIXly-correct than the first, but much harder to use. Is there any
> reason not to use signal()?
becuase it gives you greater flexibility (in terms of what should happen
when another signal is delivered while one is being handled) and
because, unlike signal() its semantics are consistent across platforms
(specifically the fact that SYSV-based systems reset the handler when a
signal is delivered, creating a window that can lead to race conditions,
while BSD-based systems do not).
In your case, however (with the caveat of possibly having to reinstall
the handler), signal should suffice.
Artie Gold, Austin, TX (finger the cs.utexas.edu account for more info)
Verbing weirds language.