From: gwyn@arl.army.mil (Doug Gwyn (ACISD/MCSB) <gwyn>)
Subject: Re: Fork bug in Sys5 (or similar) system
Date: Thu, 26 May 1994 18:08:28 GMT [thread overview]
Message-ID: <1994May26.180828.3893@arl.army.mil> (raw)
In-Reply-To: 2s0io0$248@overload.lbl.gov
In article <2s0io0$248@overload.lbl.gov> jin@eubie.lbl.gov (Guojun Jin[ITG]) writes:
>In sys5 or similar system, the fork() will misplace a file position in a pointer
>which opened by a parent and passed to children. The bugs affects only fread().
>fwrite() has not been tested yet, but similar peoblem should exist.
No, that's not a bug! It's because you didn't realize that the standard
I/O library does read-ahead buffering (block buffering). If you want to
share a file position indicator it *must* be done with a mechanism that
the operating system itself coordinates, e.g. the read() system call.
The standard I/O library maintains a "virtual" file image, some of which
(one bufferload) resides internally to the library (and thus the process
to which the instance of the library is linked) and some of which is
maintained externally by the operating system. This mechanism is also
responsible for another kind of bug, where one process fwrite()s or
fprintf()s or putc()s to a file, but the data does not seem to be there
when another process tries to read it from that file. (The data is still
in the writer's own buffer; it is flushed to the external file only under
certain special circumstances, not upon every putc() etc.)
next prev parent reply other threads:[~1994-05-26 18:08 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
1994-05-26 18:08 ` Doug Gwyn (ACISD/MCSB) <gwyn> [this message]
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