12-31-04 10:52 PM
"Alan Balmer" <albalmer@att.net> wrote in message news:8ucbt0p6bkgmdtgfdpjm8
bk1nt9mrphjgc@4ax.com...
: On Fri, 31 Dec 2004 18:48:29 GMT, Heny Townsend
: <henry.townsend@not.here> wrote:
:
: >In tracking down a subtle bug in my own code (don't ask), I noticed that
: >both GNU tar and Solaris native tar make a point of explicitly closing
: >stdout and stderr just before exiting. I don't have the Solaris source
: >(yet) but GNU tar ends the main() function like this:
: >
: > if (stdlis != stderr && (ferror (stdlis) || fclose (stdlis) != 0))
: > FATAL_ERROR ((0, 0, _("Error in writing to standard output")));
: > if (exit_status == TAREXIT_FAILURE)
: > error (0, 0, _("Error exit delayed from previous errors"));
: > if (ferror (stderr) || fclose (stderr) != 0)
: > exit_status = TAREXIT_FAILURE;
: > return exit_status;
: >
: >The fclose() of stderr is explicit and 'stdlis' appears to be an alias
: >for stdout.
: >
: >Does anyone know *why* this is done? The return from main() immediately
: >following is going to do an implicit exit() which will close all file
: >descriptors anyway. What's special about tar that it must do this?
:
: It wants to report any errors encountered in flushing the output.
Since tar originally wrote to tape: Tape ARchive.
Dan Mercer
:
: --
: Al Balmer
: Balmer Consulting
: removebalmerconsultingthis@att.net
[ Post a follow-up to this message ]
|