3.5.rc2 tty buffering bug ?

From: Dave Jones
Date: Thu Jun 14 2012 - 12:13:39 EST


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/