How do I know if a program worked as a subprocess?

My application creates subprocesses. Typically, these processes start and end without any problems. However, sometimes they fail.

I am currently using the python subprocess module to create these subprocesses. I check if the subprocess called the method call Popen.poll(). Unfortunately, since my debugger is activated during the crash, polling does not return the expected result.

I would like to see the debug window (not interrupt it) and still detect if the process crashed in python code.

Is there any way to do this?

+5
source share
3 answers

. , " " ?

+2

, - subprocess , . , subprocess.

+2

:

subprocess.check_output()

psutil ( )
, script, , , ,

import psutil
myprocess = psutil.Process(process_id) # you can find your process id in various ways of your choosing
for child in myprocess.children():
    print("Status of child process is: {0}".format(child.status()))

, psutil .

, , , .

0
source

All Articles