def die_if_parent_dies(signum=9):
if 'linux' not in sys.platform:
return
try:
import ctypes
libc = ctypes.CDLL('libc.so.6', use_errno=True)
PR_SET_PDEATHSIG = 1
result = libc.prctl(PR_SET_PDEATHSIG, signum)
if result == 0:
return True
else:
log('prctl failed: %s', os.strerror(ctypes.get_errno()))
except StandardError, ex:
sys.stderr.write(str(ex) + '\n')
评论列表
文章目录