Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
evil_child() kills all parents and siblings, leaving only itself alive to do what it pleases (like cleaning things up)
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
You can’t perform that action at this time.