0

I have 2 processes written in c, I'll call them 'parent' and 'child'. Parent creates child and child enters a loop where it does some code, then raises SIGSTOP. If a certain condition is reached, the parent needs to send the child SIGTERM, otherwise SIGCONT.

How can I send it SIGTERM while it is suspended and get exactly my desired results? By simply sending it SIGCONT then SIGTERM I'm afraid the child will reach SIGSTOP before SIGTERM is sent, and I also think the 2 signals one after the other will interfere with each other.

thanks.

0

If you have a process in a suspended state, it won't action any signals (other than SIGKILL) until it continues. A pending signal will be queued on the process.

So depending on your situation you will need to send either:

  1. SIGTERM and then SIGCONT
  2. SIGCONT

Of course this can be simplified to

if (condition) { send SIGTERM }
send SIGCONT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.