From owner-freebsd-bugs Sat Nov 10 17:20: 8 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id D96E437B420 for ; Sat, 10 Nov 2001 17:20:00 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id fAB1K0Q86325; Sat, 10 Nov 2001 17:20:00 -0800 (PST) (envelope-from gnats) Received: from segfault.monkeys.com (246.dsl6660157.rstatic.surewest.net [66.60.157.246]) by hub.freebsd.org (Postfix) with ESMTP id EE0F637B41C for ; Sat, 10 Nov 2001 17:15:08 -0800 (PST) Received: by segfault.monkeys.com (Postfix, from userid 1237) id 862796399; Sat, 10 Nov 2001 17:15:03 -0800 (PST) Message-Id: <20011111011503.862796399@segfault.monkeys.com> Date: Sat, 10 Nov 2001 17:15:03 -0800 (PST) From: rfg@monkeys.com Reply-To: rfg@monkeys.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/31906: No method available to unwind atexit(3) stack without exiting Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 31906 >Category: bin >Synopsis: No method available to unwind atexit(3) stack without exiting >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Nov 10 17:20:00 PST 2001 >Closed-Date: >Last-Modified: >Originator: Ronald F. Guilmette >Release: FreeBSD 4.3-RELEASE i386 >Organization: Infinite Monkeys & Co. >Environment: System: FreeBSD segfault.monkeys.com 4.3-RELEASE FreeBSD 4.3-RELEASE #0: Wed Aug 1 16:51:35 PDT 2001 root@:/usr/src/sys/compile/rfg20010801 i386 >Description: C programs are typically exited via a call to exit(3) however it it frequently useful to replace a running program image via a call to one of the exec*() family functions, rather than exiting the program via a call to exit(3). Unfortunately, when exiting a program via a call to one of the exec* functions, there is no obvious way to `unwind' the stack of program finalization actions that have been built up, during program execution, via successive calls to the atexit(3) function. Likewise there is no easy way to insure that all open streams are properly flushed (as would happen if exit(3) were called) prior to a call to one of the exec* functions. Ideally, there should be some standard C library function available that could be called, prior to a call to one of the exec* functions, that would invoke the set of pending atexit(3) finalization actions, and that would also flush all open streams. In effect, what I am requesting is a C library entry point that would invoke the following code, copied from the current exit(3) implementation: for (p = __atexit; p; p = p->next) for (n = p->ind; --n >= 0;) (*p->fns[n])(); if (__cleanup) (*__cleanup)(); >How-To-Repeat: This is a C library enhancement request. There is nothing to repeat. >Fix: Move the code shown above (from the exit(3) implementation) into its own function, make that function accessible via the standard C library interface, and make the implementation of exit(3) call the new function rather than having the code inline. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message