exit () function ends. Program Returns a value to the operating system, informs the program of the final state. After the exit () function is called, the control is handed over to the operating system. Before the end of the program, the exit () function will call all functions previously registered using atexit (), call them in the LIFO order, close all open files, and delete tmpfile () all temporary files created by the function. The
abort () function sends a SIGABRT signal to terminate program execution. The cleanup function registered with the atexit () function is not called. Whether the buffer zone will be cleared is related to the system. As shown in the following figure, it is cleared. But it is not disabled. When the process ends, it closes itself.
(for Ubuntu, The centos test clears the Buffer Zone .)
# Include <signal. h> # include <stdio. h> # include <stdlib. h> # include <unistd. h> voidabort (void)/* POSIX-style abort () function */{sigset_tmask; struct sigactionaction;/** caller can't ignore SIGABRT, if so reset to default. */sigaction (SIGABRT, null, & Action); If (action. sa_handler = sig_ign) {action. sa_handler = sig_dfl; sigaction (SIGABRT, & Action, null);} If (action. sa_handler = sig_dfl) fflush (null);/* flush all open stdio streams * // ** caller can't block SIGABRT; make sure it's unblocked. */sigfillset (& Mask); sigdelset (& Mask, SIGABRT);/* mask has only SIGABRT turned off */sigprocmask (sig_setmask, & Mask, null ); kill (getpid (), SIGABRT);/* send the signal * // ** if we're here, process caught SIGABRT and returned. */fflush (null);/* flush all open stdio streams */action. sa_handler = sig_dfl; sigaction (SIGABRT, & Action, null);/* reset to default */sigprocmask (sig_setmask, & Mask, null);/* just in case... */kill (getpid (), SIGABRT);/* and one more time */exit (1);/* This shoshould never be executed... */}