[lug] Is there a way to get output once it's been redirected to /dev/null?
Zan Lynx
zlynx at acm.org
Fri Jun 25 16:58:17 MDT 2010
On 6/25/10 4:35 PM, Jonathan Corbet wrote:
> On Fri, 25 Jun 2010 16:30:27 -0600
> Jeffrey Haemer<jeffrey.haemer at gmail.com> wrote:
>
>> Great idea, but I'm missing something.
>>
>> Here's the source for a sample program:
>>
>> #include<stdio.h>
>>
>> int main(void) {
>> while (1) {
>> printf("hello, world\n");
>> sleep(1);
>> }
>> }
>
> Either wait longer or put in an fflush(stdout); call. My guess is that
> stdio is buffering the output into a nice bug chunk.
That is what I think too.
The C stdio functions look at the output on startup and if it's a
terminal they default to line buffered. If it isn't a terminal then it
is chunk buffered and that is either 4 or 8K, IIRC.
--
Zan Lynx
zlynx at acm.org
"Knowledge is Power. Power Corrupts. Study Hard. Be Evil."
More information about the LUG
mailing list