File descriptors and streams and copying thereof.

Lloyd Kremer kremer at cs.odu.edu
Wed Apr 26 03:51:22 AEST 1989


In article <15039 at sequent.UUCP> bills at sequent.UUCP (Bill Sears) writes:

>It is NOT safe to assume that the file descriptor returned either
>by open(2) or the fopen(3) family will be the lowest available file
>descriptor.  Although this may be true on many machines, it is not
>guaranteed to be the case (I have worked with a machine where this
>did not always work).
>only the dup(2) system call makes that guarantee.


I do not dispute this observation in any way, although I find the
existence of a system where open() does not return the lowest available
descriptor quite curious.

It would seem to imply that this system has two different "gimme a file
descriptor" kernel routines, one guaranteeing the lowest and one not.
Also, it is common practice for systems to create the first three descriptors
originally by the sequence open(), dup(), dup().  In this system, they would
have to use another (more complicated) method to guarantee that the three
open descriptors are 0, 1, and 2, rather than, say, 13, 0, and 1.  In other
words, it seems they would have to do more work *not* to guarantee that open()
returns the lowest.

I would say that the designers of that system have never ascended the Sacred
Mountain.  They have not fasted and meditated and finally attained the
Spirit of UNIX!  :-) :-)

(Flame resistant suit on!!)

-- 
					Lloyd Kremer
					Brooks Financial Systems
					...!uunet!xanth!brooks!lloyd
					Have terminal...will hack!



More information about the Comp.lang.c mailing list