[comp.lang.c] Validity of an fd?

henry@utzoo.uucp (Henry Spencer) (04/08/90)

In article <8764@pt.cs.cmu.edu> wross@ius3.ius.cs.cmu.edu (William Ross) writes:
>    What's the quickest/easiest way to check if
>    a file descriptor points to a valid, open
>    file?

Remember whether you got it from a function which is guaranteed to return
same.  There isn't any terribly good general way of checking this.  (If
we are talking about Unix file descriptors rather than ANSI C "FILE *"s,
you might try fstat(), but that's not very portable.)
-- 
Apollo @ 8yrs: one small step.|     Henry Spencer at U of Toronto Zoology
Space station @ 8yrs:        .| uunet!attcan!utzoo!henry henry@zoo.toronto.edu