[mod.computers.vax] Open bug in VAX C V2.0

nunn@NBS-VMS.ARPA ("NUNN, JOHN C.") (11/07/85)

	
There is a bug in the open function of VAX C V2.0 which will
cause some UNIX utilities to fail when compiled and run under
VMS.  When an open is called for a file which does not exist,
the next file descriptor, which would be assigned to the file
if it existed, is assigned to the non-existent file.  The 
following code:

	
	close(0);
	fd = open("nonfile.dat",0L,0L);	/* file doesn't exist */
	if ( fd != -1 ) {		/* would be 0 if file existed */
		read(0,buffer,nbytes);
		close(0);
	}
	open("sys$input",0L,0L);	/* assume that fd = 0 */
	read(0,buffer,nbytes);

will fail because the second open doesn't actually return a file
descriptor of 0, but instead returns the next available file
descriptor.  Some UNIX code, look at VI/EX, actually count on
the second open returning an fd=0.  In this specific case adding 
"else close(0)" corrects the problem, but this may not work when 
many files are being open and (sometimes) closed.

Can someone verify whether this bug also exists in V2.1 of VAX C?
Also, does anyone know if this has been SPR'ed?
------