ultrix 2.0 _iob storage
Chris Torek
chris at mimsy.UUCP
Fri Oct 28 08:30:34 AEST 1988
In article <575 at jim.odr.oz> jon at 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 at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.wizards
mailing list