Kill background process on SIGINT
问题 I have this script, which should start a keep-alive script and Sublime Text 3 under Bash for Windows: #!/bin/dash set -e # Keep alive (in background) tail -f /dev/null & pid=$! echo "tail process id: ${pid}" echo "Keep-alive process started with Sublime Text 3\nPress SIGINT (CTRL+C) to kill it..." # Start Sublime Text 3 DISPLAY=localhost:0 /usr/bin/sublime # http://stackoverflow.com/a/19274804/1442219 trap "kill ${pid}; exit 1" INT wait This code generates: tail process id: 49 Keep-alive