Line-by-line processing when stdin is not a tty

Tim Harig usernet at ilthio.net
Wed Aug 11 06:32:41 EDT 2010


On 2010-08-11, Wolfgang Rohdewald <wolfgang at rohdewald.de> wrote:
> On Mittwoch 11 August 2010, Cameron Simpson wrote:
>> Usually you either
>> need an option on the upstream program to tell it to line
>> buffer explicitly
>
> once cat had an option -u doing exactly that but nowadays
> -u seems to be ignored
>
> http://www.opengroup.org/onlinepubs/009695399/utilities/cat.html

I have to wonder why cat knows or cares.  Since we are referring to
a single directional pipe, there is no fear of creating any kind of
race condition.  In general, I would expect that the shell opens the
pipe (pipe()), fork()s, closes its own 0 or 1 descriptor as appropriate
for each child,  copies (dup()) one the file descriptors to the
appropriate file descriptor for the child process, and exec()s to call
the new process.  Neither of the processes, in general, needs to know
anything other the to write and read from their given descriptors.



More information about the Python-list mailing list