[lug] Is there a way to get output once it's been redirected to /dev/null?

Jonathan Corbet corbet-bldrlug at lwn.net
Fri Jun 25 16:35:34 MDT 2010


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.

jon



More information about the LUG mailing list