Current-Users archive

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

Re: atexit(), dlclose() and more atexit()

> On Jun 29, 2020, at 9:09 AM, Rhialto <> wrote:
> But I wonder if there is any standards text that
> describes whether this particular scenario is supposed to work.

Quoting from "The Open Group Base Specifications Issue 7, 2018 edition"

The atexit() function shall register the function pointed to by func, to be called without arguments at normal program termination. At normal program termination, all functions registered by the atexit() function shall be called, in the reverse order of their registration, except that a function is called after any previously registered functions that had already been called at the time it was registered. Normal termination occurs either by a call to exit() or a return from main().

My reading of the standard here is that atexit() handlers are called at "normal program termination", and that "normal program termination" is explicitly defined as either a call to exit() or returning from main(), and thus any other call to atexit() handlers is expressly forbidden by the standard.

-- thorpej

Home | Main Index | Thread Index | Old Index