Writing to stdin of a process

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 26 06:30:39 PDT 2014


On Saturday, 26 April 2014 at 08:45:59 UTC, Craig Dillabaugh 
wrote:
> Can anyone tell me what I am dong wrong.

In this case, I'd close the pipe when you're done.


     pipes.stdin().writeln("Hello world");
     pipes.stdin.close;


myecho loops on stdin until it receives everything; until the 
pipe is closed.

testpipes waits for myecho to complete before termination.


The two processes are waiting on each other: testpipes won't 
close the file until it exits, and myecho won't exit until 
testpipes closes the file.

an explicit call to close breaks the deadlock.


In this case, flushing would cause the one line to appear, 
because of the buffering yazd talked about, but the program still 
wouldn't terminate since a flushed buffer still potentially has 
more coming so echo would see that line, then wait for  more..


More information about the Digitalmars-d-learn mailing list