Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: close or die

by Fletch (Bishop)
on Nov 12, 2004 at 00:50 UTC ( [id://407235]=note: print w/replies, xml ) Need Help??


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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://407235]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (9)
As of 2024-04-18 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found