From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B92913858C2C; Fri, 22 Apr 2022 06:54:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B92913858C2C From: "lh_mouse at 126 dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/105335] libiberty does not handle script exit codes correctly. Date: Fri, 22 Apr 2022 06:54:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Version: 11.3.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lh_mouse at 126 dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Apr 2022 06:54:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105335 --- Comment #3 from LIU Hao --- 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 c= odes 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 ex= its 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 ca= se of normal exit, `STATUS` is the lowest byte passed to `exit()`, which is al= so the same with Linux. It's probably not necessary to make the exit status ve= ry precise for describing the signal for this circumstance.=