ultrix 2.0 _iob storage

Jon Wells jon at jim.odr.oz
Mon Oct 24 09:08:33 AEST 1988


[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]

G'day,

Just wondering how _iob in declared in real unix systems 
(ones that dec hasn't got at).

I found a piece of code the other day.....

    ..
#ifdef BSD
nfiles = getdtablesize();
#else
nfiles = NFILES;
#endif
    ..
for ( p = &_iob[3]; p < _iob[nfiles]; p++ )
	fclose(p);
    ..

Eg. charges though _iob trying to close any stream that's open
 (apart from stdin/stdout/stderr), ignoring any errors from fclose().

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.

Is the above code deemed to be a reasonable way of doing this?

Ultrix provides a function called _fwalk() which, given a pointer to a
function, will call that function for every open stream passing it the
FILE *.

It's totally undocumented, I grep'd through every manual entry looking
for it (I found it by tracing exit(), it's name looked interresting in
nm's output).

Is _fwalk() standard on other genders of unix???
Does everyone else store all the _iobuf's in _iob as one array?
Is this another dec knows best????
Or is there a much better way of closing everything but stdin etc.????

jon
-- 


-- 



More information about the Comp.unix.wizards mailing list