python - How does process manage to keep running even though it receives SIGHUP despite being invoked with nohup? -
i testing if commands invoked nohup
indeed not sighup signal.
i confirmed if log centos box using putty, run nohup python foo.py &
foo.py contains infinite loop , if kill putty, python program still keeps running.
then wrote sig.py handles , logs signals receives sig.txt.
import signal, os def handler(sig, frame): f = open('sig.txt', 'a') f.write('signal: ' + str(sig) + '\n') f.close() in range(1, 20): if in [9, 19]: continue print 'setting signal handler for', signal.signal(i, handler) f = open('sig.txt', 'w') f.write('start\n') f.close() while true: pass
then run nohup python sig.py &
in putty terminal. close putty terminal.
i open new putty terminal , check content of sig.txt , find in it.
$ cat sig.txt start signal: 1
so seems running process still receives sighup.
if running process still receives sighup, how it manages stay alive when invoked sighup?
according wikipedia nohup
ignores sighup whereas disown
prevents signal being sent. in python script go through , set signal handlers signals overriding nohup
functionality.
Comments
Post a Comment