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

Redefine Process::Status#normal_exit? on Windows #15255

Conversation

straight-shoota
Copy link
Member

Aligns the definition of Process::Status#normal_exit? with Process::ExitReason::Normal as discusssed in #15231.

@straight-shoota straight-shoota added platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system kind:chore labels Dec 7, 2024
@straight-shoota straight-shoota self-assigned this Dec 7, 2024
@straight-shoota straight-shoota added this to the 1.15.0 milestone Dec 10, 2024
@straight-shoota straight-shoota merged commit ed7dce3 into crystal-lang:master Dec 11, 2024
69 checks passed
@straight-shoota straight-shoota deleted the chore/process_status-redefine-normal_exit branch December 11, 2024 09:07
@straight-shoota straight-shoota linked an issue Dec 11, 2024 that may be closed by this pull request
straight-shoota added a commit that referenced this pull request Dec 14, 2024
…15255] (#15267)

The change in #15255 broke `Process::Status#to_s` and `#inspect` on Windows due to the redefinition of `#normal_exit?`. Unfortunately we were missing specs for this, so it did go unnoticed.

This patch adds specs and restablishes the previous behaviour with the small improvement of treating the `exit_status` value as `UInt32` instead of `Int32`, which results in positive numbers.

```cr
# Crystal 1.14.0
Process::Status.new(LibC::STATUS_CONTROL_C_EXIT)).inspect # => "Process::Status[-1073741510]"

# master
Process::Status.new(LibC::STATUS_CONTROL_C_EXIT)).inspect # NotImplementedError: Process::Status#exit_signal

# this patch
Process::Status.new(LibC::STATUS_CONTROL_C_EXIT)).inspect # => "Process::Status[3221225786]"
```

There's still room for improvement, for example map the values to names and/or use base 16 numerals as is custom for error statuses on Windows), but I'll leave that for a follow-up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:chore platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Process::Status: What is a _normal_ exit?
3 participants