summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-12-06 16:44:23 -0800
committerdanielsdeleo <dan@opscode.com>2013-12-09 09:58:20 -0800
commita4c67900863bf5baaa6766a325cc6ecf9eaecf7b (patch)
tree8b26b51554e3a5714b47c76d10ccd39cc4b544a0 /spec
parentb148f45428299159697344ee63713650c9083c06 (diff)
downloadmixlib-shellout-a4c67900863bf5baaa6766a325cc6ecf9eaecf7b.tar.gz
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.
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/shellout_spec.rb6
1 files changed, 4 insertions, 2 deletions
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")