Skip to content

Commit 445ec9e

Browse files
authored
Avoid double sending of SIGINT to subprocesses (grosser#889)
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.
1 parent 35461d7 commit 445ec9e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/parallel_tests/test/runner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def print_command(command, env)
110110
def execute_command_and_capture_output(env, cmd, options)
111111
pid = nil
112112

113-
popen_options = {}
113+
popen_options = { pgroup: true }
114114
popen_options[:err] = [:child, :out] if options[:combine_stderr]
115115

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

0 commit comments

Comments
 (0)