Skip to content

Instantly share code, notes, and snippets.

@mariusgrigaitis
Created October 23, 2015 11:48
Show Gist options
  • Save mariusgrigaitis/b9f14350852d6b51ae4a to your computer and use it in GitHub Desktop.
Save mariusgrigaitis/b9f14350852d6b51ae4a to your computer and use it in GitHub Desktop.

Revisions

  1. mariusgrigaitis created this gist Oct 23, 2015.
    27 changes: 27 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    (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