Skip to content

Commit

Permalink
Redefine Process::Status#signal_exit? (#15289)
Browse files Browse the repository at this point in the history
Aligns `Status#signal_exit?` with `#exit_signal?` from #15284.
This includes the change that `Signal::STOP` (`0x7e`) is considered a signal by `#signal_exit?`, in concordance with `#exit_signal?`. See discussion in #15231 (comment)
  • Loading branch information
straight-shoota authored Dec 20, 2024
1 parent 22fb31b commit 7e48069
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion spec/std/process/status_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe Process::Status do
Process::Status.new(0x00).signal_exit?.should be_false
Process::Status.new(0x01).signal_exit?.should be_true
Process::Status.new(0x7e).signal_exit?.should be_true
Process::Status.new(0x7f).signal_exit?.should be_false
Process::Status.new(0x7f).signal_exit?.should be_true
end
{% end %}

Expand Down
12 changes: 7 additions & 5 deletions src/process/status.cr
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,14 @@ class Process::Status
end

# Returns `true` if the process was terminated by a signal.
#
# NOTE: In contrast to `WIFSIGNALED` in glibc, the status code `0x7E` (`SIGSTOP`)
# is considered a signal.
#
# * `#abnormal_exit?` is a more portable alternative.
# * `#exit_signal?` provides more information about the signal.
def signal_exit? : Bool
{% if flag?(:unix) %}
0x01 <= (@exit_status & 0x7F) <= 0x7E
{% else %}
false
{% end %}
!!exit_signal?
end

# Returns `true` if the process terminated normally.
Expand Down

0 comments on commit 7e48069

Please sign in to comment.