Julia doesn't consume bytes from the pipe until you try to read them to make sure the upstream pressure on the pipe is appropriately maintained (for flow control). You could read a byte by calling `read(so)`, but note that `cat` also internally buffers it's IO, so your program will probably livelock, with `cat` waiting for you to close `si` to write to `so` while you are waiting for bytes on `so` to close `si`. You can get around this by separating them into two Julia Tasks, but just realize that you must not assume any synchronization occurs between the pipes on those two tasks (other than *eventual* ordering).
On Thursday, May 12, 2016 at 7:54:41 AM UTC-4, [email protected] wrote: > > I've tried the following Example > > julia> (so,si,pr)=readandwrite(`cat`) > (Pipe(closed => open, 0 bytes waiting),Pipe(open => open, 0 bytes > waiting),Process(`cat`, ProcessRunning)) > > julia> write(si,"hallo") > 5 > > julia> so > Pipe(closed => open, 0 bytes waiting) > > julia> si > Pipe(open => open, 0 bytes waiting) > > julia> pr > Process(`cat`, ProcessRunning) > > from http://blog.leahhanson.us/post/julia/julia-commands.html > > but I would expect > > julia> so > Pipe(closed => open, 5 bytes waiting) > > What am I doing wrong? > > In this Example one has to close the inStream "si", is there a way to read > and write from "so" and "si" while keeping them open? >
