I'm running a python script but it is always stopped somehow. So I need to know who stopped this process.
Is there any tool to know who sent the signal that stopped a process?
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.