Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!ut-ngp!infotel!pollux!ndmce!gcg!lvs From: lvs@gcg.uucp (Larry V. Streepy) Newsgroups: net.unix,net.micro.pc Subject: Re: Bug in Microport stdio Message-ID: <356@gcg.uucp> Date: Wed, 5-Nov-86 14:01:36 EST Article-I.D.: gcg.356 Posted: Wed Nov 5 14:01:36 1986 Date-Received: Sun, 9-Nov-86 04:06:34 EST References: <123@gaia.UUCP> Reply-To: lvs@gcg.UUCP (Larry V. Streepy) Organization: The Genesis Group of Consultants, Dallas Lines: 38 Xref: mnetor net.unix:6173 net.micro.pc:7623 In article <123@gaia.UUCP> jon@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@seismo.css.gov CSNET: ndmce!gcg!lvs@smu