So I have a completely independent process, with a known PID.
I want to send it some kind of interrupt from another unrelated process that will cause it to 'gracefully' exit.
In linux it would look something like this :
first_script:
def signal_handler(signum, stack):
print("SIGNAL RECIEVED")
sys.exit()
signal.signal(signal.SIGUSR1, handle_signal)
while True:
print("Im working")
Second script:
known_pid = input("Enter pid")
os.kill(int(known_pid), signal.SIGUSR1)
Since, Windows doesn't support signaling in this way, it obviously won't work but I couldn't find any other simple solution (After quite extensive research).
from Send a signal/event to an independent process
No comments:
Post a Comment