From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 3AF261F45F for ; Thu, 9 May 2019 06:39:13 +0000 (UTC) Received: from localhost ([127.0.0.1]:49029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOchz-0005tn-Pb for normalperson@yhbt.net; Thu, 09 May 2019 02:39:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOchv-0005tc-JU for bug-gnulib@gnu.org; Thu, 09 May 2019 02:39:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOchu-0005Rx-PH for bug-gnulib@gnu.org; Thu, 09 May 2019 02:39:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43748) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hOchu-0005RY-Jy for bug-gnulib@gnu.org; Thu, 09 May 2019 02:39:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 98A9881E1D; Thu, 9 May 2019 06:39:05 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-116-40.ams2.redhat.com [10.36.116.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B3D35B680; Thu, 9 May 2019 06:39:02 +0000 (UTC) From: Florian Weimer To: Bernhard Voelker Subject: Re: Why does close_stdout close stdout and stderr? References: <87muk8d295.fsf@oldenburg2.str.redhat.com> <877ebcd0d7.fsf@oldenburg2.str.redhat.com> <87v9yneqk9.fsf@oldenburg2.str.redhat.com> <92136843-2556-40ad-dc5c-052f22649f0e@bernhard-voelker.de> <87mujzbn5r.fsf@oldenburg2.str.redhat.com> <16fea01d-e5b0-dc38-e34e-305922d94619@bernhard-voelker.de> <87ftpr9yqz.fsf@oldenburg2.str.redhat.com> Date: Thu, 09 May 2019 08:39:01 +0200 In-Reply-To: (Bernhard Voelker's message of "Thu, 9 May 2019 08:20:43 +0200") Message-ID: <87tve4t9mi.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 09 May 2019 06:39:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org, Eric Blake , NeilBrown , Jeff Layton Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" * Bernhard Voelker: > On 5/6/19 9:19 PM, Florian Weimer wrote: >> How would a programmer check that close_stdout has run, to determine >> that stdout and stderr are now invalid, to avoid the memory corruption? > > lib/closeout.c:98: > "Since close_stdout is commonly registered via 'atexit', [...]" > > close_stdout is used right before the process ends, so I don't see > what further actions would follow. 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. Thanks, Florian