Skip to content

Handle signal-terminated processes in exit status#1027

Merged
grosser merged 1 commit intogrosser:masterfrom
bazlo:fix/handle-nil-exit-status-in-highest-exit-status
Feb 5, 2026
Merged

Handle signal-terminated processes in exit status#1027
grosser merged 1 commit intogrosser:masterfrom
bazlo:fix/handle-nil-exit-status-in-highest-exit-status

Conversation

@bazlo
Copy link
Contributor

@bazlo bazlo commented Feb 5, 2026

Problem

When a child process is terminated by a Unix signal (e.g., SIGKILL, SIGTERM), $?.exitstatus returns nil while $?.termsig contains the signal number. This causes downstream code to fail when comparing or aggregating exit statuses.

Affected code paths

The following code in cli.rb breaks when exit_status is nil:

  1. cli.rb:102 - --highest-exit-status option:
test_results.map { |data| data.fetch(:exit_status) }.max
  1. cli.rb:120 - --test-file-limit option:
result[:exit_status] = [res[:exit_status], result[:exit_status]].max

Both fail with ArgumentError: comparison of Integer with nil failed when a test process is killed by a signal.

Solution

In execute_command_and_capture_output, ensure exit_status is always an integer:

  • Use $?.exitstatus for normal process termination
  • Use $?.termsig + 128 for signal termination (following Unix shell convention)
  • Fall back to 1 as a defensive default

The 128 + signal convention is standard in Unix shells (e.g., bash returns 137 for SIGKILL, 143 for SIGTERM).

Changes

  • lib/parallel_tests/test/runner.rb: Handle nil exitstatus from signal-terminated processes
  • spec/parallel_tests/test/runner_spec.rb: Add spec for signal termination behavior

When a child process is terminated by a Unix signal (e.g., SIGKILL,
SIGTERM), $?.exitstatus returns nil. This caused downstream code to
break when comparing exit statuses.

Following Unix shell convention, signal terminations now return
128 + signal_number (e.g., 137 for SIGKILL, 143 for SIGTERM).

Falls back to exit status 1 if neither exitstatus nor termsig is
available.
@bazlo bazlo force-pushed the fix/handle-nil-exit-status-in-highest-exit-status branch from edcd803 to 874daeb Compare February 5, 2026 03:07
@bazlo bazlo marked this pull request as ready for review February 5, 2026 03:08
Copy link
Owner

@grosser grosser left a comment

Choose a reason for hiding this comment

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

uh nice!

@grosser grosser merged commit 4dc7953 into grosser:master Feb 5, 2026
8 of 13 checks passed
@grosser
Copy link
Owner

grosser commented Feb 5, 2026

5.6.0

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