CKTIS / C
at_quick_exit — register functions for quick_exit
at_quick_exit from <stdlib.h> registers a function called by quick_exit. It returns 0 on success and a nonzero value on failure.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <stdlib.h>
int at_quick_exit(void (*func)(void));at_quick_exit accepts a pointer to a function taking no arguments and returning void. quick_exit calls registered functions in reverse registration order. An implementation must support at least 32 registrations.
Registrations are independent of atexit: exit does not run functions registered through at_quick_exit, and quick_exit skips functions registered through atexit. Afterwards, quick_exit calls _Exit; flushing stream buffers is not guaranteed. The example explicitly calls fflush(stdout).
Examples
#include <stdio.h>
#include <stdlib.h>
static void first(void)
{
if (puts("first") == EOF || fflush(stdout) == EOF)
_Exit(EXIT_FAILURE);
}
static void second(void)
{
if (puts("second") == EOF || fflush(stdout) == EOF)
_Exit(EXIT_FAILURE);
}
int main(void)
{
if (at_quick_exit(first) != 0)
return EXIT_FAILURE;
if (at_quick_exit(second) != 0)
return EXIT_FAILURE;
quick_exit(EXIT_SUCCESS);
}
Result
second first
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.