Skip to content

Instantly share code, notes, and snippets.

@coderjoe
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderjoe/10660379 to your computer and use it in GitHub Desktop.
Save coderjoe/10660379 to your computer and use it in GitHub Desktop.
Test subprocess sighup handling
run the bash script with:
./test.sh &
run the node script with:
node ./test.js >> logfile.txt &
Kill either with:
kill -1 <pid>
or
kill -s SIGHUP <pid>
setInterval(function() {
console.log("Still going!");
},1000);
#!/usr/bin/env bash
rm ~/log.txt
touch ~/log.txt
clean_sighup() {
echo "Cleanly handling SIGHUP" >> ~/log.txt
exit
}
trap clean_exit SIGHUP
while true
do
echo "Still going!" >> ~/log.txt
sleep 3s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment