Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Add options to prepend data to stdout/stderr
Browse files Browse the repository at this point in the history
Change-Id: I49ca315696a93d3872ab6f8c0d11e8fa8533bcdb
  • Loading branch information
mpage committed Jul 20, 2012
1 parent 2c598ae commit 5f08b2a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions em-posix-spawn/lib/em/posix/spawn/child.rb
Expand Up @@ -30,6 +30,8 @@ class Child
# :max => total Maximum number of bytes of output to allow the
# process to generate before aborting with a
# MaximumOutputExceeded exception.
# :prepend_stdout => str Data to prepend to stdout
# :prepend_stderr => str Data to prepend to stderr
#
# Returns a new Child instance that is being executed. The object
# includes the Deferrable module, and executes the success callback
Expand All @@ -45,6 +47,8 @@ def initialize(*args)
@input = @options.delete(:input)
@timeout = @options.delete(:timeout)
@max = @options.delete(:max)
@prepend_stdout = @options.delete(:prepend_stdout) || ""
@prepend_stderr = @options.delete(:prepend_stderr) || ""
@options.delete(:chdir) if @options[:chdir].nil?

exec!
Expand Down Expand Up @@ -164,8 +168,8 @@ def exec!

# watch fds
@cin = EM.watch stdin, WritableStream, @input.dup, "stdin" if @input
@cout = EM.watch stdout, ReadableStream, '', "stdout"
@cerr = EM.watch stderr, ReadableStream, '', "stderr"
@cout = EM.watch stdout, ReadableStream, @prepend_stdout, "stdout"
@cerr = EM.watch stderr, ReadableStream, @prepend_stderr, "stderr"

# register events
@cin.notify_writable = true if @cin
Expand Down

0 comments on commit 5f08b2a

Please sign in to comment.