[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:

>> But because the stdout isn't buffered, I can't do a meaningful `tail
>> -f' on my `fetchnews.log' file to monitor its output in real time.
>> When I do this, I get huge blobs of data filling my log file every
>> 15-30 seconds when things are running fine.  But when there's some
>> sort of problem or slowness on the part of `fetchnews', I can't see
>> what's happening to it by monitoring the log, due to this unbuffered
>> output.
>
> There is something else going on. stdout is line buffered by default.
> Try Perl's File::Tail. What OS is this? Some BSD?

/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.

setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);

at the beginning of main() will help.

Stefan


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