summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSerdar Sutay <serdar@opscode.com>2014-05-13 14:47:59 -0700
committerSerdar Sutay <serdar@opscode.com>2014-05-13 14:47:59 -0700
commitfe7e7a481baed7366f18a81103bb7a95cf5e2b2b (patch)
treeec68cf1065d2981f21984ed1d59b1cafb3af2449 /lib
parent59d13c943af14bb337589904e4b27a6460322a0a (diff)
parente30a3b6a9e4931201aab59f61ab27e60c7446b5c (diff)
downloadmixlib-shellout-fe7e7a481baed7366f18a81103bb7a95cf5e2b2b.tar.gz
Merge pull request #26 from akshaykarle/master
[#MIXLIB-19] Copy stderr to live_stream along with stdout of the subprocess
Diffstat (limited to 'lib')
-rw-r--r--lib/mixlib/shellout.rb6
-rw-r--r--lib/mixlib/shellout/unix.rb1
-rw-r--r--lib/mixlib/shellout/windows.rb4
3 files changed, 7 insertions, 4 deletions
diff --git a/lib/mixlib/shellout.rb b/lib/mixlib/shellout.rb
index e4e0435..e446448 100644
--- a/lib/mixlib/shellout.rb
+++ b/lib/mixlib/shellout.rb
@@ -53,9 +53,9 @@ module Mixlib
# to determine if the command was successful. Normally set via options to new
attr_accessor :valid_exit_codes
- # When live_stream is set, stdout of the subprocess will be copied to it as
- # the subprocess is running. For example, if live_stream is set to STDOUT,
- # the command's output will be echoed to STDOUT.
+ # When live_stream is set, stdout and stderr of the subprocess will be
+ # copied to it as the subprocess is running. For example, if live_stream is
+ # set to STDOUT, the command's output will be echoed to STDOUT.
attr_accessor :live_stream
# ShellOut will push data from :input down the stdin of the subprocss.
diff --git a/lib/mixlib/shellout/unix.rb b/lib/mixlib/shellout/unix.rb
index 03f619b..aac28f0 100644
--- a/lib/mixlib/shellout/unix.rb
+++ b/lib/mixlib/shellout/unix.rb
@@ -288,6 +288,7 @@ module Mixlib
def read_stderr_to_buffer
while chunk = child_stderr.read_nonblock(READ_SIZE)
@stderr << chunk
+ @live_stream << chunk if @live_stream
end
rescue Errno::EAGAIN
rescue EOFError
diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb
index c10c54f..832584a 100644
--- a/lib/mixlib/shellout/windows.rb
+++ b/lib/mixlib/shellout/windows.rb
@@ -165,7 +165,9 @@ module Mixlib
if ready.first.include?(stderr_read)
begin
- @stderr << stderr_read.readpartial(READ_SIZE)
+ next_chunk = stderr_read.readpartial(READ_SIZE)
+ @stderr << next_chunk
+ @live_stream << next_chunk if @live_stream
rescue EOFError
stderr_read.close
open_streams.delete(stderr_read)