You can make sure that there is data in `so` by looking at its 'bytes waiting' field. If there is indeed data in the pipe, maybe there is no newline character in it? Have you tried `readall` instead of `readline`?
-- mb On Sat, Jun 27, 2015 at 8:45 AM, Laurent Bartholdi < [email protected]> wrote: > I'm trying to interact with an exterior program, and can't get it to work > as I want. Let's say the program is "od" for example. I try: > > julia> (so,si,pr) = readandwrite(`od`) > (Pipe(open, 0 bytes waiting),Pipe(open, 0 bytes waiting),Process(`od`, > ProcessRunning)) > > julia> write(si,repeat("test\n",100)) > 500 > julia> flush(si) > Pipe(open, 0 bytes waiting) > > julia> readline(so) > ^C # nothing happens, the process is blocking output > > How do I manage to get Julia to give me the output of od? A line was > already ready after the first 16 characters of input. > > This is related to buffering: if I stuff the buffer, then I do get lines > asynchronously: > julia> (so,si,pr) = readandwrite(`od`); > julia> write(si,repeat("test\n",10000)); > julia> readline(so) > "0000000 062564 072163 072012 071545 005164 062564 072163 > 072012\n" > > However, there also seems to be a bug in Julia here: > julia> (so,si,pr) = readandwrite(`od`); > julia> write(si,repeat("test\n",100000)); > # and Julia is stuck > ^CERROR: InterruptException: > ERROR (unhandled task failure): write: broken pipe (EPIPE) > in yieldto at ./task.jl:21 > in wait at ./task.jl:309 > in wait at ./task.jl:225 > in wait_full at ./multi.jl:573 > in take! at ./multi.jl:744 > in take_ref at ./multi.jl:752 > in call_on_owner at ./multi.jl:718 > in anonymous at task.jl:86 > > julia> pr # hmmm... I wonder in which state the process is > ^CERROR: InterruptException: > > bash$ # Julia crashed >
