Trojan Horses

Barry Shein bzs at world.std.com
Thu Oct 18 11:57:07 AEST 1990


>I wonder, incidentally, why does close() return something?  Is it just that
>it's a system call?  What checks for close()'s return value?  I could see it
>being used for security checks and such, I suppose (verifying that "fd %d
>had to be closed -- CHECK THIS").

Trying to close a closed file descriptor will cause -1 to be returned
and errno set to EBADF. Close can also be interrupted (EINTR), I would
guess that's most likely to happen with socketio. These are conditions
a program might want to check for, even if (in the first case) just to
check for logic bugs in the program.
-- 
        -Barry Shein

Software Tool & Die    | {xylogics,uunet}!world!bzs | bzs at world.std.com
Purveyors to the Trade | Voice: 617-739-0202        | Login: 617-739-WRLD



More information about the Comp.unix.internals mailing list