Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: gwyn@arl.army.mil (Doug Gwyn (ACISD/MCSB) <gwyn>)
Subject: Re: Fork bug in Sys5 (or similar) system
Date: Sat, 28 May 1994 02:51:15 GMT	[thread overview]
Message-ID: <1994May28.025115.19219@arl.army.mil> (raw)
In-Reply-To: 2s4t7i$6vl@mail.fwi.uva.nl

In article <2s4t7i$6vl@mail.fwi.uva.nl> casper@fwi.uva.nl (Casper H.S. Dik) writes:
>I'm not 100% sure, but a simple fflush((FILE*) 0) is probably sufficient
>prior to fork().

Ooo, finally somebody found a use for the feature I lobbied for in X3J11!

Actually, exit() is seldom appropriate in this context; it not only does
stdio "cleanup", it also executes the atexit-registered functions, some
of which the programmer may not even realize were registered (by one of
the support libraries his application was linked with, for example).

The real heart of the matter (as I indicated in a previous post) is that
there is a fundamental difference between information that the "kernel"
coordinates and information private to the process.  In the good old
days we used to document the former in Section 2 of the UNIX Programmer's
Manual and the latter in Section 3.  POSIX.1 tried to blur the distinction
but had to reintroduce it in the guise of "underlying functions".  Since
fork() is a kernel action (aka "system call") the other operations
related to using it had better be left to the kernel to handle, i.e.
_exit() not exit(), or read() not fread().

I found the description of SVR4's attempt to unread a buffer rather
amusing, since obviously some UNIX file types simply cannot be unread.
For some reason this reminds me of the earlier UNIX System V stdio
attempts to make use of printf() etc. work reliably when invoked from
a signal handler.  In both cases, the job simply cannot be done right.
(With the ability to "hold" signals within a critical section, it is
now at least possible to get the latter right, and everyone implementing
"thread-safe" stdio has had to figure out how.)


  reply	other threads:[~1994-05-28  2:51 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> [this message]
1994-05-31  1:25     ` Peter da Silva
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