Skip to content

Instantly share code, notes, and snippets.

@unakatsuo
Created June 27, 2011 13:32
Show Gist options
  • Save unakatsuo/1048855 to your computer and use it in GitHub Desktop.
Save unakatsuo/1048855 to your computer and use it in GitHub Desktop.
hup2term.sh
#!/bin/sh
# This script converts HUP signal from parent shell to TERM signal.
# Terminate the running process which can not be halted with HUP (closing at a GNU screen window).
# Usage:
# hup2term.sh /usr/sbin/nginx -g \'daemon off\;\'
trap 'kill -TERM $wpid;' 1
echo "$*"
bash -c "$*" &
wpid=$!
wait $wpid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment