os: fix hex exit code print on 32-bit windows

We want to print hex exit codes for the large values,
but on 32-bit Windows the large values are negative.

Change-Id: I0e350b128414a9468c93eddc62d660f552c1ee05
Reviewed-on: https://go-review.googlesource.com/c/go/+/294070
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Russ Cox 2021-02-19 05:29:51 -05:00
parent 49add6ad90
commit 01eb70e3dd

View file

@ -103,7 +103,7 @@ func (p *ProcessState) String() string {
switch { switch {
case status.Exited(): case status.Exited():
code := status.ExitStatus() code := status.ExitStatus()
if runtime.GOOS == "windows" && code >= 1<<16 { // windows uses large hex numbers if runtime.GOOS == "windows" && uint(code) >= 1<<16 { // windows uses large hex numbers
res = "exit status " + uitox(uint(code)) res = "exit status " + uitox(uint(code))
} else { // unix systems use small decimal integers } else { // unix systems use small decimal integers
res = "exit status " + itoa(code) // unix res = "exit status " + itoa(code) // unix