I am writing a daemon with more than one process. once the first process is complete then it stops and needs mannual interrupt SIGINT(CTRL + C). After this next script is run.
Process 1 ended successfully.
How can add a SIGINT to proceed it further automatically ?
The question may be trivial but could only find how can we trap a given signal in a script, but how do we add one after completion of a task ?
You can kill the current bash shell and all of its children with the command kill -TERM -$$
.
Edit:
If, for example, you are launching processes like:
process1 &
process2 &
process3 &
process4
To modify it so that when any process ends it kills all the others you can use:
( process1 ; kill -TERM -$$ ) &
( process2 ; kill -TERM -$$ ) &
( process3 ; kill -TERM -$$ ) &
process4 ; kill -TERM -$$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With