Reputation: 23
I'm writing a multi-threaded program in C, where the main() changes the behavior of some signals and then spawns more threads. The question is: do the other threads continue executing when a signal arrives, or do they pause and resume execution when the signal is handled?
Thanks
Upvotes: 2
Views: 1255
Reputation: 136238
do the other threads continue executing when a signal arrives
On Linux they do because a signal is only ever delivered to one thread. Unless the signal is SIGSTOP
, which stops all threads of a process. See man signal(7)
and man pthreads(7)
for more details (ignore LinuxThreads info related to old threads implementation).
Although POSIX does not require that, so these details are OS specific.
Upvotes: 2