I'm running a script with two threads, a thread reading from a subprocess, and the main thread.
inside the main thread, I'm reading from stdin
, like so:
for line in sys.stdin:
if proc.poll() != None:
break
proc.stdin.write(line)
proc.stdin.flush()
<other things happen here>
(proc
is the external subprocess)
Now, this works well, until I want to close my program. When the process in the other thread exits, I want the whole program to stop, but the main thread still waits for something to be entered into stdin
. How can I abort that?
Basically, I want stdin
to be signaled an EOF
, but I have no idea how to do that.