Fork two processes and kill the second when the first is done

Posted by User1 on Stack Overflow See other posts from Stack Overflow or by User1
Published on 2010-04-22T21:19:31Z Indexed on 2010/04/22 21:23 UTC
Read the original article Hit count: 148

Filed under:
|

The title says it all. I want to create a bash script that will launch two processes and kill the second process when the first is done. Here's an example:

#fork first process
producer&

#fork second process
consumer&

#wait for producer to finish
...

#kill the consumer
...

I have a feeling this can get ugly but has a very simple solution. Please help me fill in the blanks.

© Stack Overflow or respective owner

Related posts about bash

Related posts about kill