On Tue, Oct 18, 2016 at 12:47 PM, Justin M. Keyes <justi...@gmail.com> wrote:
> I'm trying to confirm whether I'm doing something wrong or I'm running
> into a limitation. I want to spawn arbitrary shell commands and send
> input / capture output.
> The typical uv_spawn example (code below) works fine for
> non-backgrounded shell commands like these:
> bash -c 'tee'
> bash -c 'cat -'
> but "backgrounded" shell commands do not capture input:
> bash -c 'tee &'
> bash -c 'cat - &'
> For example, when the sample code below is modified with:
> args = "cat - &";
> and invoked with:
> $ echo foo | ./a.out
> then "foo" is not printed.
> Although intuitively it seems like this "should not" work, the reason
> I bothered to ask is that the following *does* work:
> args = "echo foo &";
> invoked with:
> $ ./a.out
> prints "foo". Here the "backgrounded" output was captured by libuv.
> But in the cases above, input does not reach the backgrounded process.
Gah, I had tunnel-vision here. Of course, these invocations behave the
same way (no output):
$ echo foo|bash -c 'tee &'
$ echo foo|bash -c 'cat - &'
So that is out of libuv's hands.
Though if anyone has insight into how or whether the streams can be
redirected (in libuv) so that input reaches the backgrounded process
(and its output is captured), that would be great.
Justin M. Keyes
You received this message because you are subscribed to the Google Groups
To unsubscribe from this group and stop receiving emails from it, send an email
To post to this group, send email to email@example.com.
Visit this group at https://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.