Search code examples
cmultithreadingsignalsexecutionpause

Do threads continue executing when a signal arrives?


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


Solution

  • 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.