Created
April 13, 2015 00:04
-
-
Save samthor/73e9d8a66642cb6915f6 to your computer and use it in GitHub Desktop.
library to run subprocesses in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Library which causes a bash script to block until killed, shutting down its | |
# child processes when complete. | |
function _death { | |
echo "killing all subprocesses" 1>&2 | |
pkill -P $$ | |
exit 0 # still need to quit | |
} | |
trap _death SIGINT SIGTERM | |
function _runner { | |
set -eu | |
while true; do sleep 3600; done | |
} | |
trap _runner EXIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment