Last active
September 1, 2015 05:54
-
-
Save calebmadrigal/f35294ca92e7848ace79 to your computer and use it in GitHub Desktop.
evil_child() kills all parents and siblings, leaving only itself alive to do what it pleases (like cleaning things up)
This file contains 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 characters
import os | |
import signal | |
import time | |
from multiprocessing import Process | |
def kill_all(parent_pid): | |
os.killpg(os.getpgid(parent_pid), signal.SIGKILL) | |
def evil_child(parent_pid): | |
print("Killing my parents and siblings...") | |
os.setpgrp() | |
kill_all(parent_pid) | |
print("Done killing everyone, but I'm still alive! HaHaHa!!!") | |
def child(name): | |
for i in range(10): | |
print("{} - {}".format(name, i)) | |
time.sleep(1) | |
def start_children(): | |
for i in ['a','b','c']: | |
p = Process(target=child, args=(i,)) | |
p.start() | |
start_children() | |
time.sleep(1) | |
p = Process(target=evil_child, args=(os.getpid(),)) | |
p.start() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment