fopen bug in Interactive ix/386 ?

Ross Inglis ross at mcdphx.UUCP
Fri May 12 03:49:32 AEST 1989


>In article <314 at edvcom.UUCP> news at edvcom.UUCP writes:
>>The following pice of code hangs because it tries to fopen() more than
>>_NFILE files. Insteed of returning a NULL pointer after the 18th call
>>it returns a 'valid' descriptor and chrashes.
>>We are using 1.0.6.

In article <579 at hcr.UUCP> larry at zeus.UUCP (Larry Philps) writes:
>Actually, there is nothing "wrong" here at all - the file descriptor really
>is valid.  In System V Rel 3, you can configure the number of allowed open
>file descriptors to be anything between 20 and 100.  However in stdio.h you
>find

Sorry, I think there's something wrong...
I was recently looking at the same problem on MCD's version of SysV. 
I found a bad loop in the stdio routine findiop().  The loop would
incorrectly return one more _iob than was legal, because it assumed
that a pointer _lastbuf was pointing to the last useable buffer when, in
fact, it pointed PAST the last buffer.  We recoded the five-line loop which
fixed the hang-up problem and allowed stdio to happily return a NULL
pointer after 20 (or whatever) files even though the kernel had NOFILES set
to 100.

BTW The hang appeared to be due to the fact that the sprintf() routine
reserves that last + one buffer for its personal use (and expects it to
remain unused).

Ross.



More information about the Comp.unix.questions mailing list