Bug 31906 - [libc] No method available to unwind atexit(3) stack without exiting
Summary: [libc] No method available to unwind atexit(3) stack without exiting
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 4.3-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2001-11-11 01:20 UTC by Ronald F. Guilmette
Modified: 2020-08-02 23:25 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Ronald F. Guilmette 2001-11-11 01:20:00 UTC
	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;)
        if (__cleanup)


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.
How-To-Repeat: 	This is a C library enhancement request.  There is nothing to repeat.
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:23 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped