When the process is running we can use returncode
to check its state.
p = subprocess.Popen(command, shell=True)
retrun_code =p.wait()
print(retrun_code)
The documentation for the returncode attribute says:
The child return code, set by
poll()
andwait()
. if it isNone
value indicates that the process hasn’t terminated yet.
I am running FFmpeg commands using a subprocess. In some cases, when a file already exists, it will prompt to confirm overwrite.
File 'output.mp4' already exists. Overwrite? [y/N]
Similar to return code, how can I check when the prompt is shown in the process? More Precisely, How do I tell if process is running or waiting for user input?