Skip to content
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

Improve Process::Status#to_s for abnormal exits on Windows #15283

Conversation

straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented Dec 17, 2024

Abnormal exit statuses on Windows are indicated by specific status values which correlate to LibC constants.
This patch changes Status#to_s (and #inspect) to return the name of the constant if available. This improves usability because it's easier to interpret the status.

Follow-up on #15267

@straight-shoota straight-shoota added kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system labels Dec 17, 2024
@straight-shoota straight-shoota self-assigned this Dec 17, 2024
@straight-shoota straight-shoota force-pushed the feat/process_status-stringify-windows-abnormal branch from 3b67473 to f36709e Compare December 17, 2024 12:57
@straight-shoota straight-shoota force-pushed the feat/process_status-stringify-windows-abnormal branch from f36709e to f3d9f77 Compare December 17, 2024 13:00
@straight-shoota straight-shoota added this to the 1.15.0 milestone Dec 17, 2024
@straight-shoota straight-shoota merged commit 7326cef into crystal-lang:master Dec 18, 2024
69 checks passed
@straight-shoota straight-shoota deleted the feat/process_status-stringify-windows-abnormal branch December 18, 2024 10:20
straight-shoota added a commit that referenced this pull request Dec 20, 2024
Status numbers on Windows are usually represented in hexadecimal notation. This applies that for all large exit status values (above `UInt16::MAX`, inspired from https://cs.opensource.google/go/go/+/refs/tags/go1.23.4:src/os/exec_posix.go;l=117-121).

This again improves usability because it's easier to interpret unknown status values and compare them with listings sharing the typical number format.

In #15283 we already changed `Status#to_s` to print the name of known values. But not all status codes are named.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants