Python親プロセスが終了すると、サブプロセスが自動的に終了する方法


PR_SET_PDEATHSIG (since Linux 2.1.57)
              Set the parent process death signal of the calling process to arg2
              (either a signal value in the range 1..maxsig, or 0 to clear).  This is
              the signal that the calling process will get when its parent dies.
              This value is cleared for the child of a fork(2).
 
  
 
  
import ctypes 

libc = ctypes.CDLL('libc.so.6')  

pid = os.fork() 
if pid == 0:  
    libc.prctl(1, 15)  
    # something in child

elif pid > 0:
    # something in child

libc.prctl(1,15)は、機能する文です.
 
   http://xiaoxia.org/2012/03/05/prctl/