Skip to content

Instantly share code, notes, and snippets.

@mariusgrigaitis
Created October 23, 2015 11:48
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 mariusgrigaitis/b9f14350852d6b51ae4a to your computer and use it in GitHub Desktop.
Save mariusgrigaitis/b9f14350852d6b51ae4a to your computer and use it in GitHub Desktop.
(venv)➜ /tmp cat test3.sh
#!/bin/bash
trap handle SIGINT
# run if received
handle()
{
kill -2 $CURRENT_PID
echo -en "\n Exiting Current process [$CURRENT_PID] $?\n"
exit $?
}
python -c "while True: pass" &
CURRENT_PID=$!
wait "$CURRENT_PID"
(venv)➜ /tmp ./test3.sh&
[1] 78470
(venv)➜ /tmp kill -2 78470
Exiting Current process [78473] 0
[1] + 78470 done ./test3.sh
(venv)➜ /tmp ps aux | grep python
mgrigaitis 78473 99,9 0,0 2464024 3780 s000 RN 2:48 0:17.36 python -c while True: pass
mgrigaitis 78481 0,0 0,0 2432772 480 s000 R+ 2:48 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn python
(venv)➜ /tmp python --version
Python 2.7.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment