Situation:
I am writing a program in C that maintains a number of threads. Once a thread ends, a new one is created.
Each thread forks - the child runs a process via exec() and the parent waits for it to finish.
In addition, there is a signal handler thread that waits for signals. If SIGINT is detected then it tells the main thread to stop creating threads so eventually all the threads end and the program can exit.
Signals are blocked in all threads except of course the signal handler thread.
Aim:
I want to be able to terminate the program by sending SIGTERM. This would work by stopping the main thread creating new threads and also terminating the running processes created by threads.
Problem:
If signals are blocked in all the threads, how can I send a signal to the running processes to terminate them?
Is there some way to make the spawned processes only receive signals sent from the main program and not signals sent to the main program?