[support.start.term] (original) (raw)

17 Language support library [support]

17.5 Startup and termination [support.start.term]

[Note 1:

The header declares the functions described in this subclause.

— _end note_]

[[noreturn]] void _Exit(int status) noexcept;

Effects: This function has the semantics specified in the C standard library.

Remarks: The program is terminated without executing destructors for objects of automatic, thread, or static storage duration and without calling functions passed toatexit() ([basic.start.term]).

[[noreturn]] void abort() noexcept;

Effects: This function has the semantics specified in the C standard library.

Remarks: The program is terminated without executing destructors for objects of automatic, thread, or static storage duration and without calling functions passed toatexit() ([basic.start.term]).

int atexit(_c-atexit-handler_* f) noexcept;int atexit(_atexit-handler_* f) noexcept;

Effects: Theatexit()functions register the function pointed to by fto be called without arguments at normal program termination.

It is unspecified whether a call to atexit() that does nothappen beforea call to exit() will succeed.

Implementation limits: The implementation shall support the registration of at least 32 functions.

Returns: Theatexit()function returns zero if the registration succeeds, nonzero if it fails.

[[noreturn]] void exit(int status);

Effects:

int at_quick_exit(_c-atexit-handler_* f) noexcept;int at_quick_exit(_atexit-handler_* f) noexcept;

Effects: The at_­quick_­exit() functions register the function pointed to by fto be called without arguments when quick_­exit is called.

It is unspecified whether a call to at_­quick_­exit() that does nothappen beforeall calls to quick_­exit will succeed.

[Note 3:

Theat_­quick_­exit() functions do not introduce a data race ([res.on.data.races]).

— _end note_]

[Note 4:

The order of registration could be indeterminate if at_­quick_­exit was called from more than one thread.

— _end note_]

[Note 5:

Theat_­quick_­exit registrations are distinct from the atexit registrations, and applications might need to call both registration functions with the same argument.

— _end note_]

Implementation limits: The implementation shall support the registration of at least 32 functions.

Returns: Zero if the registration succeeds, nonzero if it fails.

[[noreturn]] void quick_exit(int status) noexcept;

Effects: Functions registered by calls to at_­quick_­exit are called in the reverse order of their registration, except that a function shall be called after any previously registered functions that had already been called at the time it was registered.

Objects shall not be destroyed as a result of calling quick_­exit.

If control leaves a registered function called by quick_­exit because the function does not provide a handler for a thrown exception, the function std​::​terminate shall be called.

[Note 6:

A function registered via at_­quick_­exitis invoked by the thread that calls quick_­exit, which can be a different thread than the one that registered it, so registered functions cannot rely on the identity of objects with thread storage duration.

— _end note_]

After calling registered functions, quick_­exit shall call _­Exit(status).

Remarks: The function quick_­exit is signal-safewhen the functions registered with at_­quick_­exit are.