I have a process in Linux that has two POSIX threads running this function:
void *
threadFunc(void *args)
{
(void)args;
long id = pthread_self();
while (1) {
printf("Hello from %li\n", id);
sleep(1);
}
return NULL;
}
I send the process a SIGSTOP
. Both threads stop printing to the screen. I send a SIGCONT
and both threads resume their printing.
Based on my understanding of how multithreaded processes handle signals, I would have thought that only one thread would have received the signal. Why is it that both threads are stopped?