Path: utzoo!attcan!uunet!yale!cmcl2!polyof!john From: john@polyof.UUCP ( John Buck ) Newsgroups: comp.bugs.sys5 Subject: Re: Serious bug in stdio on some ``System V'' derivatives Summary: fdopen() side effects Message-ID: <384@polyof.UUCP> Date: 7 Oct 88 01:59:42 GMT References: <591535074.12423@minster.york.ac.uk> Reply-To: john@polyof.poly.edu ( John Buck ) Organization: Polytechnic University Lines: 22 Aside from the NOFILE vs. _NFILE size problems, fdopen() introduces another little (possibly confusing) side effect to stdio. Namely, fd = open("somefile", 2); ... fp1 = fdopen(fd, "r"); fp2 = fdopen(fd, "r+"); Problem here is that fp1 and fp2 SHARE the same IO buffer, since the way "stdio" determines the buffer is via the bufendtab[file_descriptor]. If two "file handles" (FILE *'s) are open to the same file descriptor, buffer clashing will occur. This is something to watch out for, because I have been stung by it a couple of times. john@polyof.poly.edu john@polygraf.bitnet john@[128.238.10.100] (polyof.poly.edu) trixie!polyof!john