Determining EOF character

Erik Max Francis max at
Sun Feb 18 14:35:41 EST 2001

Daniel Klein wrote:

> When managing child processes (like with popen2.popen2) I have
> occasion to do
>         instream.readlines()
> to get all lines in a list rather than
>         instream.readline()
> which gets the next line terminated with 'os.linesep'.
> On Windows the child process needs to send a ^Z in response to
> readlines() and
> on UNIX it needs to send ^D. I don't know what this is on MAC.

This isn't the way you should signal end of file.  You should signal it
the client closing his end of the pipe.  In fact, what you suggest above
may work on Windows, but it won't work on UNIX -- under UNIX, an end of
file isn't indicated with a sentinel character in the stream, but rather
with an out-of-bounds indicator (the underlying file structure has an
end-of-file flag).  As I recall, Windows/DOS does much the same thing,
but also treats a ^Z as an explicit end-of-file indicator.

 Erik Max Francis / max at /
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ I just don't know why they're shooting at us.
\__/ Capt. Benjamin "Hawkeye" Pierce
    Esperanto reference / http://mirror/alcyone/max/lang/esperanto/
 An Esperanto reference for English speakers.

More information about the Python-list mailing list