Bug in Microport stdio
Larry V. Streepy
lvs at gcg.uucp
Thu Nov 6 05:01:36 AEST 1986
In article <123 at gaia.UUCP> jon at gaia.UUCP (Jonathan Corbet) writes:
>I have found what appears to be an obnoxious bug in the standard I/O
>library for Microport unix. Rather than let other folks out there track
>it down themselves, I thought I would pass it on:
>
>Essentially, the problem is this: when you fopen() a file for "r+" access,
>read from the file, then attempt to write, the data written gets lost. This
>happens even if you are careful to do a fseek() like the manual says.
>This breaks certain software, such as netnews. The solution I have found
>is to get the current position with ftell(), close and reopen the file,
>fseek() to the position of interest, then do the write.
>
> [text of test program removed]
>
>Jonathan Corbet
>{hao | nbires}!gaia!jon
This problem also manifests itself on the AT&T PC6300+. I had the same
problem bringing up netnews (i.e. the ACTIVE file wasn't being updated).
The problem can be worked around in a slightly more efficient manner.
After opening the file set the stream to unbuffered via setbuf(3S).
as an example:
if( (fp = fopen( "file_to_open", "r+" )) == NULL ) {
/* handle error */
}
else setbuf( fp, (char *)NULL );
/* rest of code */
When I applied this to the test program Jonathan supplied it worked fine.
Larry V. Streepy, Jr. "Waiting is"
The Genesis Group of Consultants, (214)530-6884
2905 Green Oaks Dr., Garland Tx, 75040 USA
UUCP: {seismo!c1east | cbosgd!sun | allegra}!convex!ndmce!gcg!lvs
INTERNET: ndmce!gcg!lvs at seismo.css.gov CSNET: ndmce!gcg!lvs at smu
More information about the Comp.unix
mailing list