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.
foo & pid_foo=$!
bar & pid_bar=$!
wait $pid_foo
kill $pid_bar
But perhaps you could just run foo | bar
(if that happens to work with stdin/stdout handling).
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