New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subprocess reports signal as negative exit status, not documented #71354
Comments
If a command run by subprocess.check_call() exits because of a signal, e.g. SIGPIPE, Popen._handle_exitstatus() encodes the signal number as a negative return code. check_call() then raises that as a CalledProcessError, which describes it as "returned non-zero exit status -13". This is misleading and undocumented. CalledProcessError.__str__() should check if self.returncode is negative and if so return a string indicating that it was "signal 13", not "exit status -13". Better yet, it should include the descriptive name of the signal, e.g., SIGPIPE. And, the documentation for the subprocess module should note that a signal is converted into a negative returncode. |
I'll take this as a documentation update for 3.5 and a feature request for better message text in 3.6. |
docs updated (7b12180481da and 19d77132f38d). working on the error message update. |
New changeset f2d13349ea5d by Gregory P. Smith in branch 'default': |
New changeset 1022d09d11e5 by Gregory P. Smith in branch 'default': |
So this is mostly done... one oddity which may warrant improvement though: signal numbers have multiple names. ie: SIGABRT is also known as SIGIOT, etc. This is likely to be confusing to if the error message is surfaced to the user as most users only know one common name rather than all of them as described in their system headers or the signal(7) man page. I'd rather Python not be in the business of picking which name is more popular, but it can generate different error messages for the same signal across repeated runs due to hash randomization changing the order of the map in the signal.Signals type. run python3.5 -c 'import signal; print(signal.Signals(6))' a handful of times to see this. |
New changeset 365b5e6163a6 by Gregory P. Smith in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: