Determining EOF character

Grant Edwards grante at
Tue Feb 20 00:27:21 CET 2001

In article <slrn99334p.2fk.qrczak at qrnik.zagroda>, Marcin 'Qrczak' Kowalczyk wrote:
>Sun, 18 Feb 2001 20:30:35 -0800, Daniel Klein <danielk at> pisze:
>> I don't want to terminate the connection, I only want to know when
>> the server (child) process has stopped sending.
>You must invent your own way of signalling this. A way which does not
>interfere with normal data. There is no other system-wide concept of
>stopping sending than closing the connection.
>When you press ^D on a Unix terminal, it is not sent in the stream.
>It only flushes the line without '\n' at the end. If it was pressed
>at the beginning of a line (or after a previous ^D), the read()
>syscall returns 0, which is interpreted as the end of file.

IIRC, it's the tty driver that interprets the ^D and generates an EOF
condition.  The rest of Unix doesn't know ^D from your uncle Bob.

>The file is not physically closed - the process can read further.
>But I think it works only for terminals and such signal cannot be
>sent through a pipe. The read end returns 0 only when the write end
>closes its pipe handle, and no character is treated specially.

Grant Edwards                   grante             Yow!  Ha ha  Ha ha Ha ha
                                  at               Ha Ha Ha Ha -- When will I
                                 EVER stop HAVING FUN?!!

More information about the Python-list mailing list