From: casper@fwi.uva.nl (Casper H.S. Dik)
Subject: Re: Fork bug in Sys5 (or similar) system
Date: 27 May 1994 13:40:02 GMT [thread overview]
Message-ID: <2s4t7i$6vl@mail.fwi.uva.nl> (raw)
In-Reply-To: ddj.770040899@gradient
ddj@gradient.gradient.com (Dave Johnson) writes:
><Enter Old Fozzard mode>
>I don't remember where I learned not to do exit() in a child that
>hasn't exec'ed (maybe the BSTJ Nov '78 Unix paper?). This sort of
>lore should be clearly stated in the manual pages (under both fork AND
>exit in this case). Word-of-Net is nice, but you'd think after all
>these years it would be officially noted.
><Exit Old Fozzard mode>
I think you can find this in the old BSD vfork() manual pages,
and perhaps in the newer ones as well.
It says something to the effect that you should call _exit() after
vfork() and then goes on to note in brackets: Even with fork it is
wrong to call exit since buffered data would then be flushed twice.
This used to apply only to output buffers, as flushing input buffers
was something people didn't do.
The SVR4 stdio implementation does an
lseek(fileno(buf), -unread characters in buf, SEEK_CUR).
if it maintained a proper idea of the current file position, it could
instead do:
lseek(fileno(buf), offset where we're supposed to be , SEEK_SET).
However, this would require an lseek on each input buffer prior to
each read. Though lseek isn't world's most expensive system call,
and its costs are dwarfed in comparison, it may still be something
you want to avoid.
I'm not 100% sure, but a simple fflush((FILE*) 0) is probably sufficient
prior to fork().
Casper
next prev parent reply other threads:[~1994-05-27 13:40 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 [this message]
1994-05-28 2:51 ` Doug Gwyn (ACISD/MCSB) <gwyn>
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