[Top][All Lists]

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

Re: Why does close_stdout close stdout and stderr?

From: Kamil Dudka
Subject: Re: Why does close_stdout close stdout and stderr?
Date: Fri, 10 May 2019 09:28:22 +0200

On Friday, May 10, 2019 12:17:11 AM CEST Paul Eggert wrote:
> On 5/8/19 11:39 PM, Florian Weimer wrote:
> > atexit handlers run before ELF destructors (and some C++ destructors).
> > There can also be multiple such handlers.  So it's not true that an
> > atexit handler always runs last.
> OK, but this shouldn't be a problem with any applications currently
> using close_stdout. At least, none of the applications I know about.

How would you know if they did?

As long as you link libraries dynamically, any of the directly or indirectly 
linked libraries can introduce an ELF destructor or atexit() handler anytime, 
which would take an immediate effect even on your already built applications.
People also like to use instrumentation libraries enforced by LD_PRELOAD in 
their test environment.  Those can easily clash with such cleanup handlers.


> I can see the need for a module that does the trick you mention (with
> suitable error handling) instead of closing stdout, for applications
> that have nontrivial atexit handlers or destructors. This module's API
> shouldn't use identifiers like "close_stdout", though, since they
> wouldn't actually closing stdout.

reply via email to

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