Avoiding `readavailable()` when communicating with long-lived external program

RE: readavailable()

I have recently encountered a problem with readavailable() myself. When I used the following, I noticed only a part of my file was read in:

f = open("myimg.png")
data = readavailable(f) #Only reads part of the file?!?
close(f)

On the other hand, if I simply used read(), the whole image was read in from disk:

f = open("myimg.png")
data = read(f) #This time, I get the whole file!
close(f)

So, maybe this is why there is a warning in the julia documentation:

You only get whatever your OS chooses to read (cache) into your buffer.

Possible limitation wrt Pipes?

I’m not 100% sure this statement applies to Pipe-s, though. They might react differently to the readavailable() command than IOBuffer-s do. In fact, I have observed they react differently in certain ways wrt their blocking behaviour - as mentioned in my previous post.