Created
November 24, 2009 20:39
-
-
Save stormsilver/242189 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/chef/lib/chef/mixin/command.rb b/chef/lib/chef/mixin/command.rb | |
| index ee80c7f..43af235 100644 | |
| --- a/chef/lib/chef/mixin/command.rb | |
| +++ b/chef/lib/chef/mixin/command.rb | |
| @@ -306,6 +306,9 @@ class Chef | |
| begin | |
| if args[:waitlast] | |
| b[cid, *pi] | |
| + # send EOF so that if the child process is reading from STDIN | |
| + # it will actually finish up and exit | |
| + pi[0].close_write | |
| Process.waitpid2(cid).last | |
| else | |
| # This took some doing. | |
| diff --git a/chef/spec/unit/mixin/command_spec.rb b/chef/spec/unit/mixin/command | |
| index 3705e41..92337b2 100644 | |
| --- a/chef/spec/unit/mixin/command_spec.rb | |
| +++ b/chef/spec/unit/mixin/command_spec.rb | |
| @@ -41,6 +41,15 @@ describe Chef::Mixin::Command, "popen4" do | |
| end | |
| end | |
| + it "should end when the child process reads from STDIN and a block is given" | |
| + lambda {Timeout.timeout(2) do | |
| + popen4("ruby -e 'while gets; end'", :waitlast => true) do |pid, stdin, | |
| + (1..5).each { |i| stdin.puts "#{i}" } | |
| + end | |
| + end | |
| + }.should_not raise_error | |
| + end | |
| + | |
| describe "when a process detaches but doesn't close STDOUT and STDERR [CHEF-5 | |
| it "returns immediately after the first child process exits" do |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment