From a4c67900863bf5baaa6766a325cc6ecf9eaecf7b Mon Sep 17 00:00:00 2001 From: danielsdeleo Date: Fri, 6 Dec 2013 16:44:23 -0800 Subject: Always send KILL to process group There is not a good way to reliably detect whether all grandchildren have exited after sending a TERM to the process group; if the child has correctly exited, grandchildren (which may be unresponsive) will have been adopted by init (ppid == 1) so the parent cannot wait() on them. To ensure no stuck grandchildren are left, send a KILL to the process group after allowing the processes time to clean up. --- spec/mixlib/shellout_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb index 582aef4..0a6f9b2 100644 --- a/spec/mixlib/shellout_spec.rb +++ b/spec/mixlib/shellout_spec.rb @@ -884,7 +884,7 @@ describe Mixlib::ShellOut do shell_cmd.status.termsig.should == 9 log_output.string.should include("Command execeded allowed execution time, sending TERM") - log_output.string.should include("Command did not exit from TERM, sending KILL") + log_output.string.should include("Command execeded allowed execution time, sending KILL") end end @@ -916,7 +916,8 @@ describe Mixlib::ShellOut do let(:cmd) do ruby_wo_shell(<<-CODE) STDOUT.sync = true - trap(:TERM) { print "got term in child\n" } + + trap(:TERM) { print "got term in child\n"; exit!(123) } fork do trap(:TERM) { print "got term in grandchild\n" } sleep 10 @@ -929,6 +930,7 @@ describe Mixlib::ShellOut do # note: let blocks don't correctly memoize if an exception is raised, # so can't use executed_cmd lambda { shell_cmd.run_command}.should raise_error(Mixlib::ShellOut::CommandTimeout) + shell_cmd.stdout.should include("got term in child") shell_cmd.stdout.should include("got term in grandchild") -- cgit v1.2.1