From fd631b9945cf33a1e5af849900cf6219b050e321 Mon Sep 17 00:00:00 2001 From: Ricky Zhou Date: Fri, 1 Jan 2010 15:39:36 -0500 Subject: Do not close stdout or stderr in execute. Closing stdout and stderr would sometimes cause failures when a program that is executed with squelched output tries to write to them. This reverts to the previous behavior of reopening them to /dev/null. --- lib/puppet/util.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index cc2822f3b..3752a6dac 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -291,20 +291,23 @@ module Util begin output_read.close - if arguments[:stdinfile] - $stdin.reopen(arguments[:stdinfile]) - else - $stdin.close - end if arguments[:squelch] - $stdout.close + output_write.close + $stdout.reopen('/dev/null', 'w') + $stderr.reopen('/dev/null', 'w') else $stdout.reopen(output_write) + if arguments[:combine] + $stderr.reopen(output_write) + else + $stderr.reopen('/dev/null', 'w') + end end - if arguments[:combine] - $stderr.reopen(output_write) + + if arguments[:stdinfile] + $stdin.reopen(arguments[:stdinfile]) else - $stderr.close + $stdin.close end 3.upto(256){|fd| IO::new(fd).close rescue nil} -- cgit