7

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 ?

Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
krishnakant
  • 355
  • 1
  • 4
  • 17

1 Answers1

4

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 -$$
ccarton
  • 3,556
  • 16
  • 17
  • 5
    This appears to answer a different question than what is being asked here. – tripleee Sep 26 '16 at 14:23
  • @tripleee, His question isn't very clear, but I've updated my answer with more details about the exact situation that I'm solving. – ccarton Sep 26 '16 at 14:45