[Bug other/105335] libiberty does not handle script exit codes correctly.

lh_mouse at 126 dot com gcc-bugzilla@gcc.gnu.org
Fri Apr 22 06:54:35 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105335

--- Comment #3 from LIU Hao <lh_mouse at 126 dot com> ---
Windows uses a full-width 32-bit exit status, but there is no standard
convention for them.

1. If a process has exited successfully, the status is zero. This matches
POSIX.
2. If a process has exited due to a fault, the status is an enumeration of
`NTSTATUS`, for example it's `0xC000001D` for illegal instructions, and
`0xC0000005` for invalid memory access, and so on. The guarantee of these codes
is that the lowest byte is never zero.
3. The MSYS2 bash (N.B. I don't know whether they have made such behavior
different from Cygwin, but I suspect not) checks whether a child process exits
successfully. If not, and the `-e` option is passed, it exits with `(SIGNAL <<
8) | (STATUS & 0xFF)`, where `SIGNAL` is the same with Linux, and in the case
of normal exit, `STATUS` is the lowest byte passed to `exit()`, which is also
the same with Linux. It's probably not necessary to make the exit status very
precise for describing the signal for this circumstance.


More information about the Gcc-bugs mailing list