I'm trying to interact with a process using std.process and redirected stdin/stdout/stderr.<div>What would be the recommended way?</div><div><br></div><div>For example:</div><div>----</div><div>auto pipes=pipeShell("myprocess",Redirect.all);</div>
<div>while(true){</div><div>  pipes.stdin.rawWrite(some_command);</div><div><div>  foreach (line; pipes.stdout.byLine) {</div><div>    //do something with line</div><div>  }</div></div><div>}</div><div><div>----</div></div>
<div><br></div><div>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.</div><div><br></div>
<div>What's the right approach?</div><div>* fcntl(fd, F_SETFL, O_NONBLOCK); didn't seem to work</div><div>* reading pipes.stdout inside a separate thread?</div><div>In that second case, how to cleanly dispose of a blocked thread when we no longer need it?</div>
<div><br></div><div>Any detailed example would help.</div><div>Thanks!</div><div><br></div><div><br></div><div><br></div><div><br><div><br></div></div><div><br></div>