bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH sed] ck_fclose should unlink *before* calling do_ck_fclose.


From: Eric Blake
Subject: Re: [PATCH sed] ck_fclose should unlink *before* calling do_ck_fclose.
Date: Tue, 03 Jun 2014 15:41:58 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

On 06/03/2014 02:55 PM, Stanislav Brabec wrote:
> NeilBrown wrote:
>> If do_ck_fclose gets an error from fclose() it will call
>> panic() which will try to close everything on the list.
> 
> There is a question: Why this code is needed at all? Is there a
> platform, where exit(4) later in panic() keeps open file descriptors?

exit() is guaranteed to close fds, but NOT guaranteed to affect return
status if there was an error detected during the close.  We'd rather
close things manually, so that we can force a non-zero exit status via
_exit() if the close failed (which, for some filesystems such as NFS, is
all too real of a possibility).


> And even: Why the fflush() is called before fclose()? fclose() should
> always flush. Isn't the error of fclose() sufficient? (Especially if
> both end in panic().)

Again, fclose() is guaranteed to attempt a flush, but not guaranteed to
do sane reporting of errors in that process.  Doing a manual fflush()
first gives us better error reporting.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]