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: Stanislav Brabec
Subject: Re: [PATCH sed] ck_fclose should unlink *before* calling do_ck_fclose.
Date: Tue, 03 Jun 2014 22:55:04 +0200

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(3p) says:
       The exit() function shall then flush all open streams with
       unwritten buffered data, close all open  streams,  and remove all
       files created by tmpfile().

It was added here:

2004-03-13  Paolo Bonzini  <address@hidden>

        Exit as soon as possible on an I/O error, and with
        a better error message.
    ...
        (panic): Unlink temporary files before exiting.


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().)

fclose(3p) says:
DESCRIPTION
       The  fclose() function shall cause the stream pointed to by
       stream to be flushed and the associated file to be closed. Any
       unwritten buffered data for the stream shall be written to the
       file; any unread buffered data shall be discarded.

It was added here:

2002-06-08  Paolo Bonzini  <address@hidden>
       * lib/utils.c (ck_fclose): Work on stdout as well if stream == NULL
        and flush before closing to check for errors


Well, and the check for EBADF in ck_fflush() looks like a hack that
could hide a problem elsewhere.

It was added here:

2002-10-28  Paolo Bonzini  <address@hidden>
        
        * lib/utils.c: Don't fail for EBADF in fflush

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: address@hidden
Lihovarská 1060/12                            tel: +49 911 7405384547
190 00 Praha 9                                 fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76




reply via email to

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