Hi Eric,

the problem here is that the kernel is blocking the process because there's
nobody reading on the
other side (since the writing process is blocked so it can't do any
reading). We can probably do some
things to improve the situation, but for now I'd recommend the following:
- Start reading before writing, e.g. using
t = @async read(pout)
...
# Later
wait(t)
- Break up the write into smaller pieces. If you want to be absolutely sure
that the reading happened,
you can also call `Base.process_events(false)` after doing a write.


On Fri, Oct 7, 2016 at 2:56 PM, Eric Davies <iam...@gmail.com> wrote:

> I'm trying to write a bunch of data to a process, then read out the
> result. Replaced the process here with `cat -` because that's close
> enough.
>
> function bloop(size)
>       data = "f" ^ size
>
>       print("start")
>       (pout, pin, p) = readandwrite(`cat -`)
>       print("write")
>       write(pin, data)
>       print("flush")
>       flush(pin)
>       print("close")
>       close(pin)
>       print("read")
>       output = read(pout)
>       print("close")
>       close(p)
>
>       println()
>
>       output
> end
>
> If `size <= 146944`, this succeeds. If `146944 < size <= 147456`, Julia
> blocks forever at the `read` call in a `kevent` system call. If `size >
> 147456`, Julia blocks forever at the `write` call in a `write` system call.
>
> How can I make this work?
>

Reply via email to