0

I'm running a python test script, which calls something that looks like the following:

def execute():
    p = subprocess.Popen(params)
    return (p)

The python test script is called by a shell script, which has a time out kill signal. After a period of time, a kill signal is sent to the python script. The kill signal will kill the script, but it leaves the Popen subprocess.

How would I go about catching the kill signal in the python script and sending it to the subprocess?

  • see https://stackoverflow.com/questions/4789837/how-to-terminate-a-python-subprocess-launched-with-shell-true – Nahuel Fouilleul Jul 20 '17 at 19:03
  • From https://stackoverflow.com/questions/284325/how-to-make-child-process-die-after-parent-exits : Child can ask kernel to deliver SIGHUP (or other signal) when parent dies by specifying option PR_SET_PDEATHSIG in prctl() syscall like this: `prctl(PR_SET_PDEATHSIG, SIGHUP)`. [Python prctl](https://pypi.python.org/pypi/python-prctl) – Fabien Jul 20 '17 at 19:07

0 Answers0