lkml.org 
[lkml]   [2012]   [Jun]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject3.5.rc2 tty buffering bug ?
I found something odd that happens with redirection.

this code...



#include <stdio.h>

void main()
{
printf("begin\n");

if (fork() != 0)
printf("child\n");
else
printf("parent\n");

printf("end\n");
}

usually exits before the child gets to print anything, so stdout looks like..

begin
parent
end

but when redirected to a file, sometimes it prints what we expect, but other times
(if the child exits first) it seems to print..

begin
child
end
begin
parent
end


How does 'begin' get printed a second time ?

Dave



\
 
 \ /
  Last update: 2012-06-14 19:01    [W:0.040 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site