I think you are going about this entirely the wrong way.
There are two propper ways, that I can see:
Rewrite your program to work as an event loop:
call select($rbits,$wbits,$ebits,0) to find FDs
ready for I/O, and process them
Write two threads: One does select($rbits,$wbits,$ebits,00.1) </code>(Note the non-zero timeout), which only makes note of which filehandles are ready for I/O, and leaves the information somewhere for the main process to find.
If the "process I/O buffer" is an operation with a guaranteed upper time limit, the first option is probably preferable.