unix pipes + python

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Fri Dec 29 04:20:03 EST 2000


29 Dec 2000 10:56:47 +1100, Timothy Docker <timd at macquarie.com.au> pisze:

> This script behavious almost as expected. I end up with the text
> echoed back, but the 'cat' subprocess is left running - I was
> expecting it to exit when the write side of the pipe was closed in the 
> parent, but it is still reading from fd 0.

Close the write side in the child, just after forking. As long as
someone has the pipe open for writing, cat does not see the end
of file (even if someone == cat itself).

I would also close the read side in the parent.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list