Skip to content

Commit

Permalink
Avoid double sending of SIGINT to subprocesses (#889)
Browse files Browse the repository at this point in the history
Standard bash behavior when pressing Ctrl+C is to send SIGINT to the
foreground process group. This combines well with standard fork behavior
because subprocesses are started in the same group, so a multi-process
program is correctly terminated without any explicit signal handling.

It however does not work well in cases where signals are handled
explicitly like here, because on Ctrl+C the subprocesses receive two
SIGINTs - one directly from the shell and one from the interrupt handler
in the `CLI` class. This in turn can prevent graceful shutdown in the
subprocesses.

The specific example that prompted this fix was interrupting feature
specs using selenium. In case of a double interrupt the browser process
will sometimes remain running after rspec is terminated.
  • Loading branch information
rdokov committed Jan 14, 2023
1 parent 35461d7 commit 445ec9e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parallel_tests/test/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def print_command(command, env)
def execute_command_and_capture_output(env, cmd, options)
pid = nil

popen_options = {}
popen_options = { pgroup: true }
popen_options[:err] = [:child, :out] if options[:combine_stderr]

output = IO.popen(env, cmd, popen_options) do |io|
Expand Down

0 comments on commit 445ec9e

Please sign in to comment.