If you are able to wait at the end of your main process, you can add something like:
import signal
siginfo = signal.sigwaitinfo({signal.SIGTERM})
print("got %d from %d by user %d\n" % (siginfo.si_signo,
siginfo.si_pid,
siginfo.si_uid))
(Adapted from here : works on Python 3.5.2 on Linux)
which will block your script and make it wait until it gets a SIGTERM, then it'll print out the pid of the process that sent the SIGTERM. You can swap SIGTERM for SIGINT if it was a SIGINT that stopped your program. Unfortunately you can only catch signals in the main process and not in seperate threads, see here for more information.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.