From nick@specialix.com  Thu Sep 11 16:50:18 1997
Received: from relay1.UU.NET (relay1.UU.NET [192.48.96.5])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id QAA08949
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 11 Sep 1997 16:50:12 -0700 (PDT)
Received: from slxinc.specialix.com by relay1.UU.NET with SMTP 
	(peer crosschecked as: slxinc.specialix.com [192.65.145.1])
	id QQdgpj11058; Thu, 11 Sep 1997 19:47:53 -0400 (EDT)
Received: from zephyr.specialix.com by specialix.com id aa10176;
          11 Sep 97 16:48 PDT
Received: by zephyr.specialix.com 
        (8.8.5//ident-1.0) id QAA01738; Thu, 11 Sep 1997 16:47:32 -0700 (PDT) 
Message-Id: <199709112347.QAA01738@zephyr.specialix.com>
Date: Thu, 11 Sep 1997 16:47:32 -0700 (PDT)
From: nsayer@quack.kfu.com
Reply-To: nsayer@quack.kfu.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: stdio does not flush on fork()
X-Send-Pr-Version: 3.2

>Number:         4514
>Category:       bin
>Synopsis:       stdio does not flush on fork()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 11 17:00:01 PDT 1997
>Closed-Date:    Fri Sep 12 11:26:09 PDT 1997
>Last-Modified:  Fri Sep 12 11:27:33 PDT 1997
>Originator:     Nick Sayer
>Release:        FreeBSD 2.2.2-RELEASE i386
>Organization:
Just me
>Environment:

>Description:

If the stdio buffers are not flushed, a fork() will replicate
the filled buffer to the child, resulting in doubling the data.
It is inconsistent, however you slice it, to have one printf
call result in multiple outputs.

>How-To-Repeat:

#include <stdio.h>

main()
{

printf("this will appear twice.");

fork();

}

>Fix:

>Release-Note:
>Audit-Trail:

From: John-Mark Gurney <gurney_j@efn.org>
To: nsayer@quack.kfu.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/4514: stdio does not flush on fork()
Date: Fri, 12 Sep 1997 01:41:55 -0700

 nsayer@quack.kfu.com scribbled this message on Sep 11:
 > If the stdio buffers are not flushed, a fork() will replicate
 > the filled buffer to the child, resulting in doubling the data.
 > It is inconsistent, however you slice it, to have one printf
 > call result in multiple outputs.
 
 I think this is actually a user error...  fork is a system call..
 and teaching a system call about how to use a library isn't a very
 good idea...  so you just need to make sure you:
 fflush(NULL);
 before you fork...
 
 -- 
   John-Mark Gurney                          Modem/FAX: +1 541 683 6954
   Cu Networking
 
   Live in Peace, destroy Micro$oft, support free software, run FreeBSD
State-Changed-From-To: open->closed 
State-Changed-By: jmg 
State-Changed-When: Fri Sep 12 11:26:09 PDT 1997 
State-Changed-Why:  
originator confirms that FreeBSD isn't the only one... there is no 
easy fix for the problem, just make sure you call fflush(NULL) before 
you fork if you use stdio.. 
>Unformatted:
