You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by John Siracusa <si...@mindspring.com> on 2004/08/14 04:34:07 UTC

Checking the return value of close() (was: Apache::DBI and DBIx::*)

On 8/13/04 5:23 PM, Perrin Harkins wrote:
> On Fri, 2004-08-13 at 17:15, John Siracusa wrote:
>> Something tells me you haven't been bitten by this bug yet, but let me save
>> you the grief.  When, say, your disk fills up and you let that file handle
>> go out of scope, close() will silently fail when trying to flush the buffers
>> to disk.
> 
> If you're concerned about that, you should actually check the return
> value of print() as well.

Believe me, everyone should be "concerned about that" :)  Also, the return
value from print() is not always useful.  In the situation I described, for
example, print will happily return 1 so long as what it's printing fits in
the output buffer, regardless of whether or not the data is actually going
to make it to the disk.  Checking the return value from close() gives a more
reliable answer, and you only have to do it once at the end.

-John



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Checking the return value of close() (was: Apache::DBI and DBIx::*)

Posted by John Siracusa <si...@mindspring.com>.
On 8/13/04 10:34 PM, John Siracusa wrote:
> In the situation I described, for example, print will happily return 1 so long
> as what it's printing fits in the output buffer, regardless of whether or not
> the data is actually going to make it to the disk.

Er, that should read "regardless of whether or not the disk is full", since
"making it to disk" is outside the scope of Perl's core functions (and may
be outside the scope of the OS if the hardware lies :)

-John



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html