function
<cstdlib>

quick_exit

_Noreturn void quick_exit (int status);
[[noreturn]] void quick_exit (int status) noexcept;
Terminate calling process quick
Terminates the process normally by returning control to the host environment after calling all functions registered using at_quick_exit.

No additional cleanup tasks are performed: No object destructors are called. Although whether C streams are closed and/or flushed, and files open with tmpfile are removed depends on the particular system or library implementation.

If status is zero or EXIT_SUCCESS, a successful termination status is returned to the host environment.
If status is EXIT_FAILURE, an unsuccessful termination status is returned to the host environment.
Otherwise, the status returned depends on the system and library implementation.

If a program calls both exit and quick_exit, or quick_exit more than once, it causes undefined behavior.

Parameters

status
Status code.
If this is 0 or EXIT_SUCCESS, it indicates success.
If it is EXIT_FAILURE, it indicates failure.

Return Value

none (the function never returns).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* quick_exit example */
#include <stdio.h>      /* puts */
#include <stdlib.h>     /* at_quick_exit, quick_exit, EXIT_SUCCESS */

void fnQExit (void)
{
  puts ("Quick exit function.");
}

int main ()
{
  at_quick_exit (fnQExit);
  puts ("Main function: Beginning");
  quick_exit (EXIT_SUCCESS);
  puts ("Main function: End");  // never executed
  return 0;
}

Output:
Main function: Beginning
Quick exit function.


Data races

Concurrently calling this function multiple times has no effect.
Calls to at_quick_exit that do not complete before the call to this function may not succeed (depends on particular library implementation).

Exceptions (C++)

No-throw guarantee: this function never throws exceptions.

If any of the functions registered with at_quick_exit throws an exception, terminate is automatically called.

See also