Skip to content

Instantly share code, notes, and snippets.

@schipiga
Last active December 6, 2019 15:20
Show Gist options
  • Save schipiga/d021d23eeb06951cff77fcc70f4670be to your computer and use it in GitHub Desktop.
Save schipiga/d021d23eeb06951cff77fcc70f4670be to your computer and use it in GitHub Desktop.
from multiprocessing import Process
import time
import signal
import os
import psutil
def start():
raise Exception('BOOM!')
def handle_chld(signum, frame):
os.waitpid(-1, os.WNOHANG)
signal.signal(signal.SIGCHLD, handle_chld)
def main():
proc = Process(target=start)
proc.start()
time.sleep(1)
print('is process alive?', psutil.pid_exists(proc.pid))
print('is process alive?', proc.is_alive())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment