Xref: utzoo comp.unix.wizards:20748 comp.bugs.sys5:1230 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!ames!sgi!rpw3@rigden.wpd.sgi.com From: rpw3@rigden.wpd.sgi.com (Rob Warnock) Newsgroups: comp.unix.wizards,comp.bugs.sys5 Subject: Re: stdio broken in SysV? Message-ID: <51697@sgi.sgi.com> Date: 24 Feb 90 06:08:28 GMT References: <2010@sauron.Columbia.NCR.COM> Sender: rpw3@rigden.wpd.sgi.com Reply-To: rpw3@rigden.UUCP (Robert P. Warnock) Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 38 In article <2010@sauron.Columbia.NCR.COM> wescott@micky.columbia.ncr.com (Mike Wescott) writes: +--------------- | I am trying to port a program. It blows up in fprintf because SysV stdio | has the implicit assumption that a given file descriptor will be used by | no more than one stdio stream. Which is broken? The program that does: | fpin = fdopen(fd,"r"); | fpot = fdopen(fd,"w"); | Or the stdio that blows up in memcpy() called from doprnt() called by | fprintf() in the same program? +--------------- This is a well-known problem to anyone who has ported any Berkeley networking applications to System V. IMHO, Sys5's broken, but it's that way in all the S5R2's I've seen. (Did it make it into S5R3? Will it still be there in S5R4?) +--------------- | BTW the "implicit assumption" mentioned above is due to the fact that | the array _bufendtab[] is indexed by fp->_file rather than by fp-_iob | or built into the FILE structure itself. +--------------- Your diagnosis is exactly correct. On the other hand, Berkeley Unix stores the bufend pointers in the FILE struct (no problem). By the way, a simple workaround for this problem (*hack* *hack*) is: fpin = fdopen(fd,"r"); fpot = fdopen(dup(fd),"w"); -Rob ----- Rob Warnock, MS-9U/510 rpw3@sgi.com rpw3@pei.com Silicon Graphics, Inc. (415)335-1673 Protocol Engines, Inc. 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311