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

Add Process::ExitReason and Process::Status#exit_reason #13052

Merged

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Feb 7, 2023

Resolves #12284.

As of this PR the compiler itself should no longer depend on Signal directly.

@HertzDevil HertzDevil added kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system labels Feb 7, 2023
@HertzDevil HertzDevil marked this pull request as ready for review February 13, 2023 12:42
@HertzDevil HertzDevil self-assigned this Feb 13, 2023
spec/std/process/status_spec.cr Outdated Show resolved Hide resolved
Comment on lines +297 to +322
private def exit_message(status)
case status.exit_reason
when .aborted?
if status.signal_exit?
signal = status.exit_signal
if signal.kill?
"Program was killed"
else
"Program received and didn't handle signal #{signal} (#{signal.value})"
end
else
STDERR.puts "Program received and didn't handle signal #{signal} (#{signal.value})"
"Program exited abnormally"
end
else
STDERR.puts "Program exited abnormally, the cause is unknown"
when .breakpoint?
"Program hit a breakpoint and no debugger was attached"
when .access_violation?, .bad_memory_access?
# NOTE: this only happens with the empty prelude, because the stdlib
# runtime catches those exceptions and then exits _normally_ with exit
# code 11 or 1
"Program exited because of an invalid memory access"
when .bad_instruction?
"Program exited because of an invalid instruction"
when .float_exception?
"Program exited because of a floating-point system exception"
when .unknown?
"Program exited abnormally, the cause is unknown"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this couldn't be useful on its own and moved into Process::Status#description or similar?
This doesn't need to happen in this PR.

src/process/status.cr Outdated Show resolved Hide resolved
src/process/status.cr Outdated Show resolved Hide resolved
src/process/status.cr Outdated Show resolved Hide resolved
@straight-shoota straight-shoota added this to the 1.8.0 milestone Feb 15, 2023
@straight-shoota straight-shoota merged commit 9758567 into crystal-lang:master Feb 16, 2023
@HertzDevil HertzDevil deleted the feature/process-exit-reason branch February 27, 2023 12:44
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.

Platform-independent process exit reasons
3 participants