How can I get my Child process to terminate the Parent process?
I was thinking something along the lines of...
Child gets Parent Process's PID and terminates the parent using
Here's my code
from multiprocessing import Process, Value import keyboard import sys def KeyboardScan(v): Paused = False while True: if keyboard.is_pressed('x'): v.value = 1 print("Child Terminate") sys.exit() #Child process's code if __name__ == "__main__": val = Value('i', 0) p = Process(target=KeyboardScan, args=(val,)) p.start() #Parent process's code
So if the key
x is pressed, the Child should terminate the Parent and itself.
In this code the
value exists only because originally I had a while loop in my Parent process to check for the value. If the value is 1 then it performs a
sys.exit() on the Parent process.
But I'm trying to avoid using this method.