Last active
August 29, 2015 14:06
Revisions
-
nirs renamed this gist
Sep 6, 2014 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ from __future__ import print_function import signal import signalfd import sys -
nirs created this gist
Sep 6, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ from __future__ import print_function import os import signal import signalfd import sys import threading def report(): mask = signalfd.sigprocmask(signalfd.SIG_BLOCK, []) print('- pid: %s thread: %s mask: %s' % ( os.getpid(), threading.current_thread(), mask)) print('parent starting pid: %s' % os.getpid()) signalfd.sigprocmask(signalfd.SIG_BLOCK, [signal.SIGTERM, signal.SIGINT, signal.SIGHUP]) report() print('starting a thread in parent...') threading.Thread(target=report).start() pid = os.fork() if pid: os.waitpid(pid, 0) else: print('child starting pid: %s...' % os.getpid()) report() print('starting a thread in child...') threading.Thread(target=report).start() pid = os.fork() if pid: os.waitpid(pid, 0) else: print('subchild starting pid: %s...' % os.getpid()) report() print('starting a thread in sub child...') threading.Thread(target=report).start()