[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [leafnode-list] Can fetchnews un-buffer stdout?



Matthias Andree <ma@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:

> Stefan Wiens schrieb am Samstag, den 13. Januar 2001:
> 
> > /usr/local/sbin/fetchnews -vvv \
> > 1>>/var/spool/news/log/fetchnews.log 2>&1
> > 
> > redirects stdout to a non-terminal file, which disables line
> > buffering.
> 
> Why should a shell redirection switch from line to full buffering?

Because stdio is smart (or tries to be).  It automatically checks via
the appropriate ioctl() calls (or perhaps simply via isatty(), which
usually sits atop ioctl) what kind of device that stdout is going to.
If it's going to a terminal, the output is line buffered.  If it's
going to a file and perhaps other types of devices, the output is no
longer line buffered, and we get the behavior which I mentioned above.

This, by the way, is standard stdio behavior which has been in
Unix and its cousins for 10-20 years.

The calls mentioned by Stefan Wiens should indeed be used if
line-buffering is to be ensured.

And by the way, this has nothing to do with Perl::Tail, which gives
the same results as I mentioned above, due to the lack of line
buffering of non-tty stdout output.


-- 
 Lloyd Zusman
 ljz@xxxxxxxxxx

-- 
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list