Skip to content

Instantly share code, notes, and snippets.

@otherwiseguy
otherwiseguy / deathsig
Created July 15, 2014 21:40
An example how in python on linux you can ensure that a signal gets passed to a child on its parent's death
#!/usr/bin/env python
from prctl import prctl, PDEATHSIG # https://pypi.python.org/pypi/prctl/1.0.1
import signal as sig
import subprocess
p = subprocess.Popen(['yes'], preexec_fn=lambda: prctl(PDEATHSIG, sig.SIGTERM))
p.communicate()