This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: stderr vs. STDERR_FILENO


Jonathan Lennox <lennox@cs.columbia.edu> writes:

> Zack Weinberg <zack at codesourcery dot com> writes:
>> For what it's worth I think this is primarily a documentation issue -
>
> It just occured to me -- no, unfortunately, this is a correctness issue.
>
> This C++ program is well-defined by the standard -- it invokes
> std::terminate, which invokes abort().
...

> Now, as a matter of QoI, I suspect that in almost every actual C library a
> write to a closed stderr will always fail with EOF, which means that my
> little program still has the behavior mandated by the standard.

I was suspicious that glibc might crash on a write to a closed stderr,
but experimentally it does not - returns EOF, as desired.

A middle road: By default, std::terminate just calls abort(), but
provide an environment variable which enables verbose mode.  The
programmer can use it only when appropriate.  (Should probably be
ignored in privileged programs.)

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]