in reply to Re: close or die
in thread Making an array out of each line in a file

According to man 2 close (FreeBSD, OpenBSD and OS X) the two cases are:

ERRORS Close() will fail if: [EBADF] D is not an active descriptor. [EINTR] An interrupt was received.

</unecessarily complete information>

But agreed, always checking the return value from system calls is good practice (just like you should always check your optics before testing your high powered laser when that jerk Kent's around . . . </Real Genius>).

Update: Ooop, tilly is correct below. Perl's close is more akin to fclose(3) than close(2) and can return with errno of any of the errors from close(2) or fflush(3) (and fflush(3) in turn may set errno if an underlying write(2) failed).

Replies are listed 'Best First'.
Re^3: close or die
by tilly (Archbishop) on Nov 12, 2004 at 02:34 UTC
    That's actually not complete information since Perl's close is more complicated than the corresponding C call. In particular when you close a file in Perl it also flushes data to the filehandle, which can fail if the filesystem is full.

    Would you like to get an error message when your file got truncated because the filesystem was full?