You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Linux when a process gets killed by a signal the exit code is negative and the abs value of the exit code is the signal number (e.g. -6 is SIGABRT).
Python's subprocess.Popen will return the correct negative exit code if the application is killed with a signal. pustil.Popen does not.
I think this is bug because psutil.Popen is supposed to have the same interface as subprocess.Popen.
Either this is a bug which should be fixed or it is intentional behaviour. If it intentional is should really be documented.
I found this stackoverflow posted about this problem from a few years back but I'm not sure if the OP ever reported this problem.
You can see that the exit code from subprocess.Popen is negative indicating it was killed by a signal. psutil.Popen returns a positive exit code so it looks like the process was not killed by a signal even though it was!
The text was updated successfully, but these errors were encountered:
Summary
On Linux when a process gets killed by a signal the exit code is negative and the abs value of the exit code is the signal number (e.g.
-6
isSIGABRT
).Python's
subprocess.Popen
will return the correct negative exit code if the application is killed with a signal.pustil.Popen
does not.I think this is bug because
psutil.Popen
is supposed to have the same interface assubprocess.Popen
.Either this is a bug which should be fixed or it is intentional behaviour. If it intentional is should really be documented.
I found this stackoverflow posted about this problem from a few years back but I'm not sure if the OP ever reported this problem.
http://stackoverflow.com/questions/25639578/psutil-subprocess-return-code-when-process-killed
How to reproduce
I did this use
psutil==5.0.1
installed withpip
.Write a python program that aborts.
abort.py
Now in an interactive python console try running it with
subprocess.Popen
Try running with
psutil.Popen
You can see that the exit code from
subprocess.Popen
is negative indicating it was killed by a signal.psutil.Popen
returns a positive exit code so it looks like the process was not killed by a signal even though it was!The text was updated successfully, but these errors were encountered: