Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!ukma!uflorida!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: ultrix 2.0 _iob storage Keywords: ultrix stdio _iob _fwalk() Message-ID: <14196@mimsy.UUCP> Date: 27 Oct 88 22:30:34 GMT References: <575@jim.odr.oz> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 44 In article <575@jim.odr.oz> jon@jim.odr.oz (Jon Wells) writes: >[attempt two, sorry if you've seen this before, I may have messed >up the posting, anyway, I didn't get any response and I'd like to know] (I saw a response, but anyway...:) >[found code that reads] >for ( p = &_iob[3]; p < _iob[nfiles]; p++ ) > fclose(p); >You can't do this with ultrix (2.0) as _iob is only 3 slots long, all >other struct _iobuf's are allocated dynamically so &_iob[3].... >just points off into the weeds. The same is true in 4.3BSD, except that NSTATIC _iob's exist. NSTATIC happens to be 20. >Is the above code deemed to be a reasonable way of doing this? No. >Ultrix provides a function called _fwalk() .... Also found in 4.3BSD. (Guess which group invented it. :-) ) >Is _fwalk() standard on other genders of unix??? No. >Or is there a much better way of closing everything but stdin etc.???? No. What you can do in the presence of a dpANS-conformant system is this: (void) fflush((FILE *)NULL); for (fd = 3; fd < nfiles; fd++) (void) close(fd); which leaves the FILEs open but closes the underlying descriptors, after pushing any pending output. If you are about to exec()---this is the only reasonable use for the above---it will work. But nobody handles fflush(NULL) yet. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris