On Linux, os.pipe()
is just a wrapper around pipe(2). Both return a pair of file descriptors. Normally one would use lseek(2) (os.lseek()
in Python) to reposition the offset of a file decsriptor as a way to get the amount of available data. However, not all file descriptors capable of seeking.
On Linux trying lseek(2) on a pipe will return an error, see the manual page. That's because a pipe is more or less a buffer between a producer and a consumer of data. The size of that buffer is system dependant.
On Linux, a pipe has a 64 kB buffer, so that is the most data you can have available.
Edit: If you can change the way your subprocess works, you might consider using a memory mapped file, or a nice big piece of shared memory.
Edit2: Using polling objects is probably faster than select.