On Thu, 2004-08-05 at 01:50, Greg Ewing wrote: > Chris McDonough <chrism at plope.com>: > > > The following program demonstrates that a particular usage of select > > (under Linux at least) always returns the output side of a pipe > > connected to a child process' stdout as "ready" after it gets any output > > from that child process, even if the child process has no further data > > to provide after it has provided a bit of data to the parent. > > > > Or am I doing something silly? > > > > for fd in r: > > sys.stdout.write(os.read(fd, 1024)) > > You're not taking account of the possibility of EOF. When > the child process finishes and closes its end of the pipe, > the select will always report the pipe as ready for reading, > because it is -- subsequent reads will return immediately > with 0 bytes. > > You need to check whether the read returned 0 bytes, and > take that as meaning that the child process has finished. Of course! Thanks. Let us speak no more of this. ;-) - C
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4