I have several python scripts that I start collectively from a shell script as follows:
As I develop, I often want to stop these processes. I usually do this by pressing ctrl + C, but unfortunately several python programs keep (zeromq) sockets open. This means that I need to manually find them (I use lsof -i) and kill them with the PID.
So, I am looking for an easier way to automatically kill these python processes from the shell when I press ctrl + C. In https://stackoverflow.com/a/212928/ ... I found code that supposedly should do what I need. I just donβt understand anything about the code and how I could adapt it to my needs.
Will anyone be so kind as to help me here?
cat >work.py <<'EOF' import sys, time, signal signal.signal(signal.SIGINT, signal.SIG_DFL) for i in range(10): time.sleep(1) print "Tick from", sys.argv[1] EOF chmod +x work.py function process { python ./work.py $1 } process one & wait $! echo "All done!"
kramer65
source share