Skip to content

Instantly share code, notes, and snippets.

@bkj
Created June 25, 2018 21:31
Show Gist options
  • Save bkj/4ba1b2828df846c6b2261e65bee4c8cb to your computer and use it in GitHub Desktop.
Save bkj/4ba1b2828df846c6b2261e65bee4c8cb to your computer and use it in GitHub Desktop.
#!/bin/bash
cleanup() {
echo "cleanup";
local pids=$(jobs -pr);
[ -n "$pids" ] && kill $pids;
};
trap "cleanup" INT QUIT TERM EXIT
# Put this at the beginning of a file to kill children
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment