Program support utilities

From Cppreference

Jump to: navigation, search

Contents

[edit] Program termination

The following functions manage program termination and resource cleanup.

Defined in header <cstdlib>
abort
causes abnormal program termination (without cleaning up)
(function)
exit
causes normal program termination with cleaning up
(function)
quick_exit (C++11)
causes normal program termination without completely cleaning up
(function)
_Exit (C++11)
causes normal program termination without cleaning up
(function)
atexit
registers a function to be called on exit() invocation
(function)
at_quick_exit (C++11)
registers a function to be called on quick_exit invocation
(function)
Execution outcome indicators
EXIT_SUCCESS
indicates successful program execution
(macro constant)
EXIT_FAILURE
indicates unsuccessful program execution
(macro constant)

[edit] Communicating with the environment

system
calls the host environment's command processor
(function)
getenv
access to the list of environment variables
(function)

[edit] Signals

Several functions and macro constants for signal management are provided.

Defined in header <csignal>
signal
sets a signal handler for particular signal
(function)
raise
runs the signal handler for particular signal
(function)
Signal handling strategies
SIG_DFL
default signal handling
(macro constant)
SIG_IGN
signal ignored
(macro constant)
SIG_ERR
error was encountered
(macro constant)
Signal types
SIGABRT
abnormal termination
(macro constant)
SIGFPE
floating point exception
(macro constant)
SIGILL
invalid instruction
(macro constant)
SIGINT
interactive attention request sent to the program
(macro constant)
SIGSEGV
invalid memory access
(macro constant)
SIGTERM
termination request sent to the program
(macro constant)

[edit] Non-local jumps

Defined in header <csetjmp>
setjmp
saves the context
(function)
longjmp
jumps to specified location
(function)
Types
jmp_buf
execution context type
(function)