Skip to content

Process::Status#success? returns nil if the process has not exited - #3260

Merged
ksss merged 1 commit into
ruby:masterfrom
mmporong:process-status-success-nil
Oct 27, 2026
Merged

ksss merged 1 commit into
ruby:masterfrom
mmporong:process-status-success-nil

Conversation

@mmporong

Copy link
Copy Markdown
Contributor

Process::Status#success? returns nil when the process has not exited, for example when it was killed by a signal. The RDoc comment above the signature already lists that case (success? -> true, false, or nil), but the return type was bool:

pid = spawn("sleep 5")
Process.kill(:KILL, pid)
_, status = Process.wait2(pid)
status          # => #<Process::Status: pid 2166906 SIGKILL (signal 9)>
status.success? # => nil

This changes the return type to bool? and adds Process_StatusInstanceTest#test_success?, which checks the true (exit), false (exit 1) and nil (child killed with SIGKILL) cases with assert_send_type.

Tested with Ruby 4.0.9 (ruby -Ilib bin/test_runner.rb test/stdlib/Process_test.rb, with the extension compiled from this checkout):

Result
new test, current signature 1 failure: Call trace does not match one of method definitions at the () -> nil assertion
new test, () -> bool? 4 tests, 65 assertions, 0 failures

rbs validate passes, and rubocop (with rubocop-on-rbs and the stdlib test cop) reports no offenses on the two changed files.

AI disclosure: this change was prepared with Claude Code (Claude Opus 5.5), which compared the signature with the RDoc and the runtime behavior, made the change, wrote the test and ran the checks above.

`success?` returns `nil` when the child did not exit, for example when
it was killed by a signal. The comment above the signature already
says so, but the return type was `bool`. Add a test that covers the
true, false and nil cases.

Assisted-by: Claude:claude-opus-5-5

@ksss ksss left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you!

@ksss
ksss added this pull request to the merge queue Oct 27, 2026
Merged via the queue into ruby:master with commit da4073b Oct 27, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants