Thomas
Thomas

Reputation: 2163

Test if a Popen process is waiting for input

I start a process with POpen and under normal circuimstances it should just do a job and write things to stdout which I then capture. In exceptional cases the process will fallback to an interactive mode and wait for user input. How can I detect that case and react appropriately?

Upvotes: 1

Views: 707

Answers (1)

PasteBT
PasteBT

Reputation: 2198

You can always send something to sub-process even it read nothing. So you just sent to sub-process, if it works OK, then those staff you sent will be dropped, if it failed, then you will read response.

Upvotes: 1

Related Questions