I terminate my subprocess with p.terminate
which I opened like this:
p = Popen([sys.executable, args], stdin=PIPE, stdout=PIPE, stderr=open("error.txt", 'a'))
As you can see I redirect all errors to a textfile so I can eaily read it. I missused this feature to print something into this file when the subprocess gets terminated:
signal.signal(signal.SIGTERM, sigterm_handler) # sets shutdown_flag
while True:
if shutdown_flag:
print("Some Useful information", file=sys.stderr)
However: The file is always empty. Is this because the pipe gets closed when terminate
is called and whatever is written from the subprocess at this point is lost? Or is there any other issue I just dont see here?