Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: peter@nmti.com (Peter da Silva)
Subject: Re: Fork bug in Sys5 (or similar) system
Date: Tue, 31 May 1994 01:25:36 GMT	[thread overview]
Message-ID: <id.XZY91.E5H@nmti.com> (raw)
In-Reply-To: 1994May26.181612.1484@cs.nott.ac.uk

Enter old-fogey mode.

In article <1994May26.181612.1484@cs.nott.ac.uk>,
William Armitage <wja@cs.nott.ac.uk> wrote:
> casper@fwi.uva.nl (Casper H.S. Dik) writes:
>  > You're not allowed to call exit(3) after fork(), unless you
>  > flush all files before calling fork().

> This seems to be a change introduced to support Multi-Threading.

No, it has *always* been true that you can't call any routine that might
execute fflush() after a fork() unless you know that all buffered output
streams were already fflush()ed before the fork().

This includes:

	printf, scanf, fread, fwrite, getc, getchar, fgetc, fgets,
	fprintf, fscanf, gets, puts, fputs, putc, fputc, exit, fclose,
	pclose, ...

I was aware of this in 1979, when the standard I/O library was itself pretty
new (in fact, you pulled it in explicitly with -lS), so it shouldn't be a
surprise any more.

> lpd ran away forking printer processes. Trussing things showed that the
> fclose was doing an lseek before closing. Putting an fflush before the
> fork solved the problem.

That's just a new *symptom* of an existing problem. Normally it's only output
file descriptors that trigger the bug.

I'm kinda surprised the routine didn't call close (normally you only call
open, close, pipe, dup, and other O/S-level routines between a fork and
exit/exec).
-- 
Peter da Silva                                            `-_-'
Network Management Technology Incorporated                 'U`
1601 Industrial Blvd.     Sugar Land, TX  77478  USA
+1 713 274 5180                       "Hast Du heute schon Deinen Wolf umarmt?"


  parent reply	other threads:[~1994-05-31  1:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-05-25 22:16 Fork bug in Sys5 (or similar) system Guojun Jin[ITG]
1994-05-26  7:52 ` Casper H.S. Dik
1994-05-26 18:16   ` William Armitage
1994-05-27  8:48     ` Casper H.S. Dik
1994-05-27 12:59       ` Dave Johnson
1994-05-27 13:40         ` Casper H.S. Dik
1994-05-28  2:51           ` Doug Gwyn (ACISD/MCSB) <gwyn>
1994-05-31  1:25     ` Peter da Silva [this message]
1994-05-26 18:08 ` Doug Gwyn (ACISD/MCSB) <gwyn>
1994-05-31 19:34   ` Guojun Jin[ITG]
1994-05-31 20:07     ` Casper H.S. Dik
1994-06-01 22:06     ` Peter da Silva
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox