How to determine a TProcess pipe stream is EOF

BlitzMax Forums/BlitzMax Programming/How to determine a TProcess pipe stream is EOF

Justus(Posted 2010) [#1]
Hello fellow programmers,

I am trying to call a UNIX command with CreateProcess: dig.

Starting the process is fairly simple and works fine:

CreateProcess("/usr/bin/dig website.com")


Now I am trying to get the output of said process. Problem here turns out to be to determine when the process has stopped outputting stuff. The length of the output can vary so I can not stop reading after a given number of bytes.

At least with the dig command a simple

While Not Eof(process.pipe)
    ' Reading stuff
Wend


does not work, since it obviously does not send an end of file signal.

When

process.status


returns a 0 (meaning the process is finished), the content is not yet available for reading in the process.pipe. Waiting a sec solves the problem and the output is usually completely available.

But my application is time-critical (has to be fast) and I don't like usually when it comes to programming. Plus I still wouldnt know when to stop reading.

Does anyone of you know a possible solution?