I'm trying to interact with a process using std.process and
redirected stdin/stdout/stderr.
What would be the recommended way?

For example:
----
auto pipes=pipeShell("myprocess",Redirect.all);
while(true){
  pipes.stdin.rawWrite(some_command);
  foreach (line; pipes.stdout.byLine) {
    //do something with line
  }
}
----

This doesn't work because it might block inside pipes.stdout.byLine, as the
process is requesting more inputs to be written to its stdin before
outputting more bytes to its stdout.

What's the right approach?
* fcntl(fd, F_SETFL, O_NONBLOCK); didn't seem to work
* reading pipes.stdout inside a separate thread?
In that second case, how to cleanly dispose of a blocked thread when we no
longer need it?

Any detailed example would help.
Thanks!

Reply via email to