I have a bash shell script which calls a Python script in an endless loop:
while true; do python testomat.py ; done
The Python script testomat.py
:
try:
do_something()
except KeyboardInterrupt:
print 'exit'
finally:
raise SystemExit
The problem I'm having is that I cannot stop this by Ctrl-C
. My only chance: Ctrl-z
and then kill -TERM %1
assuming that I have no other jobs running.
Would Python somehow have to propagate Ctrl-C
to the parent or how would I be able to stop this?
I know I could run the endless loop inside Python, but I actually do more in both the bash shell script and the Python script which both must continue to exist.