Write both in std output and in a file ?

Paul Jackson pj at sgi.com
Fri Jan 18 15:53:17 EST 2002


Alex clarified:
> But that is NOT the same as performing a C-level fclose on
> each FILE that a C program has opened (for writing), as I
> believe the ISO C standard specifies should happen when a
> program terminates by calling exit()

Aha - that was my confusion.  Thanks, Alex.

I was thinking of "the C language" as what the compiler parses,
and thinking of the hooks in exit() that flush stdio files as a
(long standing) hack added to the default user runtime (crt0.o)
in support of the stdio library, where the libraries in general
are not part of the language.

Clearly my viewpoint is at best "odd".  Even the first edition
K&R "The C Programming Language" (Prentice-Hall, 1978) states,
on page 154:

    "exit" calls "fclose" for each open output file,
    to flush any buffered output, then calls a routine
    named "_exit."

Well ... not that "odd".  On page 143 of the same book, K&R
write:

    Input and output facilities are not part of the C language.

They go on to explain that though not part of the language,
some description of the essentials of writing C programs that
interact with the environment is worth presenting.

In sum, I was tripping over the usual question: "is the language
just the language, or is it also the customary libraries, runtime,
O/S support and even more?"  I will remain in the "old school"
on this matter.

-- 

                          I won't rest till it's the best ...
			  Programmer, Linux Scalability
                          Paul Jackson <pj at sgi.com> 1.650.933.1373



More information about the Python-list mailing list