Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcvax!unido!edvcom!news From: news@edvcom.UUCP (News Admin) Newsgroups: comp.unix.questions Subject: fopen bug in Interactive ix/386 ? Keywords: unix,SYSV,ix/386 Message-ID: <314@edvcom.UUCP> Date: 3 May 89 14:21:06 GMT Lines: 13 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. Any suggestions, maybe someone at ico.ISC.COM reading this group ? #include #include #include int a = 1; int print_iob() { int i, cnt, file; for (i = 0; i < _NFILE; i++) { cnt = _iob[ i ]._cnt; file = _iob[ i ]._file; printf(" FD(%d) _cnt = %d _file = %d\n",i,cnt,file); } } main(argc, argv) int argc; char *argv[]; { int fod[ 200 ], i, num_opens; FILE *fd[ 200 ]; char *msg; if (argc == 2) num_opens = atoi(argv[ 1 ]); else { printf("Specify number of open()'s \n"); exit(-1); } for (i = 0; i < num_opens; i++) { fod[ i ] = open("/dev/null",O_WRONLY); printf("errno=%d,variable=%d,FOD(%d)=%d\n", errno,a,i,fod[ i ]); } for (i = 0; i < 30; i++) { printf("fopen (%d): ",i); fflush(stdout); if (fd[ i ] = fopen("/dev/null","w")) { printf("errno=%d,variable=%d,FD(%d)=%d\n", errno,a,i,fileno(fd[ i ])); print_iob(); } else { printf("fopen(%d) delivered NULL...\n",i); break; } } getchar(); exit(0); } /* end main() */ +-----------------------------------------------------------------------------+ | G}nther Moschen | UUCP : ...!uunet!mcvax!unido!edvcom!gm | | EDV-COMPAS Gmbh | FAX : +49 8331 84024 | | 8940 Memmingen W-Germany | PHONE : +49 8331 86078 | +------------------------------+----------------------------------------------+