def on_parent_exit(signame):
 def noop():
  pass
 try:
  libc = cdll['libc.so.6']
 except OSError:
  return noop
 try:
  prctl = libc.prctl
 except AttributeError:
  return noop
 signum = getattr(signal, signame)
 def set_parent_exit_signal():
  result = prctl(PR_SET_PDEATHSIG, signum)
  if (result != 0):
   raise Exception(('prctl failed with error code %s' % result))
 return set_parent_exit_signal

def on_parent_exit ( signame ) : def noop ( ) : pass try : libc = cdll [ 'libc.so.6' ] except OSError : return noop try : prctl = libc . prctl except AttributeError : return noop signum = getattr ( signal , signame ) def set_parent_exit_signal ( ) : result = prctl ( PR_SET_PDEATHSIG , signum ) if ( result != 0 ) : raise Exception ( ( 'prctl failed with error code %s' % result ) ) return set_parent_exit_signal
return a function to be run in a child process which will trigger signame to be sent when the parent process dies .