diff --git a/spec/std/process/status_spec.cr b/spec/std/process/status_spec.cr index 5561b106613b..b56f261c4b5c 100644 --- a/spec/std/process/status_spec.cr +++ b/spec/std/process/status_spec.cr @@ -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 %} diff --git a/src/process/status.cr b/src/process/status.cr index 2bbcb175c033..74ab92b329d6 100644 --- a/src/process/status.cr +++ b/src/process/status.cr @@ -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.