file descriptor vs file handle

Stanley Friesen sarima at tdatirv.UUCP
Wed Feb 27 03:03:11 AEST 1991


In article <27C9CB35.5F7 at wilbur.coyote.trw.com> cwong at charlie.coyote.trw.com (Chun Wong) writes:
>Can someone distinguish the differences between a file descriptor and
>a file handle?  I know that creat returns a file handle whereas fopen
>returns a file descriptor.  What's the difference?  Are they interchangeable?

A file handle (as you call it) is a small integer used by the operating
system (MS-DOS?) to access the file state, and allow it to perform I/O
on your behalf.

What you call a file descriptor is a pointer to an application level
structure containing state information used by the standard I/O library.
(And *only* by the standard I/O library).  Among other things, this
structure contains the file handle for the file.

Note that the terminology your documentation uses is *not* universal.
[I have only seen this terminology in the Lattice C compiler docs for
MS-DOS, though MSC may also use it].
Be aware that in most UNIX docs the term file descriptor usually refers
to what you call a file handle, and your 'file descriptor' is usually
called a 'FILE pointer'.
-- 
---------------
uunet!tdatirv!sarima				(Stanley Friesen)



More information about the Comp.lang.c mailing list