yes, it is the fault of `od`. you can see this by using `cat` instead and
observing that it works. if you play around with the thresholds in `od`,
you will observe that it is doing block-buffering of 4096 byte chunks when
the input is a pipe.
Unless you turn on write buffering (with `buffer_writes(si)`), the `write`
function implicitly calls `flush`, and will block the task until the write
completes (the actual `flush` function is a no-op). Therefore, it's best to
call write in a separate task if you are processing both ends of the pipe:
julia> (so,si,pr) = readandwrite(`od`)
(Pipe(open, 0 bytes waiting),Pipe(open, 0 bytes waiting),Process(`od`,
ProcessRunning))
julia> @async write(si,repeat("test\n",10000))
Task (done) @0x00007fe37aa0daa0
(note, the line_buffered property has no effect)
Note that Base.readavailable returns a random, non-zero number of bytes,
which is presumably not what you want?
julia> Base.readavailable(so)
135168-element Array{UInt8,1}:
...
julia> Base.readavailable(so)
61440-element Array{UInt8,1}:
...
In order to get the full output, you need to instead call:
julia> close(si)
julia> readall(so)
On Sun, Jun 28, 2015 at 9:08 AM Jeff Waller <[email protected]> wrote:
>
>
> On Saturday, June 27, 2015 at 5:03:53 PM UTC-4, [email protected] wrote:
>>
>> Is your od program flushing its output? Maybe its stuck in its internal
>> buffers, not in the pipe.
>>
>
> nah man, if it's it's od, it's not going to do that, the only thing
> simpler is cat; I suppose you could try cat.
>
> What happens when you do something like this?
>
> *julia> **fromStream,toStream,p=readandwrite(`cat`)*
>
> *(Pipe(open, 0 bytes waiting),Pipe(open, 0 bytes waiting),Process(`cat`,
> ProcessRunning))*
>
>
> *julia> **toStream.line_buffered*
>
> *true*
>
>
> *julia> **toStream.line_buffered = false*
>
> *false*
>
>
> *julia> **fromStream.line_buffered = false*
>
> *false*
>
>
> *julia> **write(toStream,"x")*
>
> *1*
>
>
> *julia> **readavailable(fromStream)*
>
> *1-element Array{UInt8,1}:*
>
> * 0x78*
>