Skip to content

Instantly share code, notes, and snippets.

@sparr
Created September 9, 2024 21:25
Show Gist options
  • Save sparr/498479a91a1a317a47b035e16f1c328c to your computer and use it in GitHub Desktop.
Save sparr/498479a91a1a317a47b035e16f1c328c to your computer and use it in GitHub Desktop.
Bash script: Wait for one process to exit
#!/bin/bash
#
# This script launches two processes and exits when either of them exits
(
do_thing_1
kill -s SIGHUP $$
) &
(
do_thing_2
kill -s SIGHUP $$
) &
# wait for one of the processes to exit and send a SIGHUP back to this shell
sleep infinity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment