This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients MrTroble, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2020-07-25.00:46:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1595638018.44.0.421987577907.issue41386@roundup.psfhosted.org>
In-reply-to
Content
In the Windows API, errors and exit status codes are all unsigned 32-bit integers. See SetLastError, GetLastError, ExitThread, ExitProcess, GetExitCodeThread, and GetExitCodeProcess. Even signed NTSTATUS and HRESULT values are commonly displayed as non-negative values, and, as exit status values, they're usually matched as unsigned integers. 

I think, if anything, it should suffice to document the range of `Popen.returncode` in Windows as a 32-bit unsigned integer.

---

Even POSIX systems in many cases have no use for the signed exit status from C exit(). The POSIX wait() and waitpid() system calls only provide the lower byte (i.e. masked by 0xFF) of the exit status. The subprocess module takes advantage of this on POSIX systems in order to reserve negative return codes to indicate termination by a signal. 

The newer waitid() system call should be able to return the signed 32-bit exit status. I think that's implemented on BSD and macOS, but waitid() in Linux 5.4 appears to only return the masked 8-bit status. For example:

    >>> p = subprocess.Popen(['python', '-c', 'import os; os._exit(-1)'])
    >>> os.waitid(os.P_PID, p.pid, os.WEXITED).si_status
    255
History
Date User Action Args
2020-07-25 00:46:58eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, MrTroble
2020-07-25 00:46:58eryksunsetmessageid: <1595638018.44.0.421987577907.issue41386@roundup.psfhosted.org>
2020-07-25 00:46:58eryksunlinkissue41386 messages
2020-07-25 00:46:57eryksuncreate