[Gambas-user] Important change in revision #6691

Benoît Minisini gambas at ...1...
Sun Nov 30 23:52:27 CET 2014


Hi,

I'm trying to fix a problem in the Gambas process management that annoys 
a lot of people for a long time.

Sometimes, the output of the process is not entirely read. Some data is 
lost.

This is because I was using a way of detecting data availability that 
was not reliable. I thought it was, but I was wrong.

Concretely, the select() system call tells you if there is data 
available to read, but, in some cases, it wakes up and there is actually 
no data to read.

So I tried to use a end-of-stream check by using various system calls 
(it depends on the type of file descriptor: file, pipe, socket...). But 
this routine sometimes fails.

To change that, I now read data ahead by chunk of 1KB before actually 
raising the Read event.

Apparently, using select() + read() is the correct way of accurately 
detecting end of stream, especially on pipes.

Consequently, if the read ahead fails, I decide there is nothing to read 
anymore and I close the stream.

Hopefully, this was not a big job, as internally read ahead was already 
implemented for optimizing the INPUT and LINE INPUT instruction.

But this is a big change that may have side effects, so I ask people who 
run Gambas projects that watch a lot of file descriptors, and read the 
output of a lot of external processes, to use that revision and report 
any problem.

Regards,

-- 
Benoît Minisini




More information about the User mailing list