All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Jones <davej@redhat.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: 3.5.rc2 tty buffering bug ?
Date: Thu, 14 Jun 2012 12:13:31 -0400	[thread overview]
Message-ID: <20120614161331.GA29687@redhat.com> (raw)

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


             reply	other threads:[~2012-06-14 16:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14 16:13 Dave Jones [this message]
2012-06-14 16:22 ` 3.5.rc2 tty buffering bug ? Dave Jones
2012-06-14 16:30 ` Andreas Schwab
2012-06-14 16:41 ` Alan Cox
2012-06-15 10:32 ` Cong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120614161331.GA29687@redhat.com \
    --to=davej@redhat.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.