On_exit () function instructions
Abstract:This article describes how to use the on_exit () function on the Linux manual page, using the on_exit () function to register the termination handler.
NAME
On_exit-used to register the termination handler executed before the exit () function is executed.
SYNOPSIS
# Include <stdlib. h>
Int on_exit (void (* function) (int, void *), void * arg );
Feature Test Macro Requirements for glibc (see feature_test_macros (7 )):
On_exit (): _ BSD_SOURCE | _ SVID_SOURCE
DESCRIPTION
On_exit () is used to register the terminate handler. When the handler is called exit () or returned from main, there are two parameters to terminate the handler, the first parameter is from the status in the Last exit () function call, and the second parameter is from arg in the on_exit () function.
If a function is registered multiple times, it will be called multiple times.
When a child process is generated by calling the fork () function, it inherits all the termination handlers of the parent process. after successfully calling the exec series functions, all termination handlers will be deleted.
RETURN VALUE
0 is returned for success, and a non-0 value is returned for failure.
CONFORMING
This function comes from SunOS 4, but is also present in glibc. it no longer occurs in Solaris (SunOS 5 ). portable application shoshould avoid this function, and use the standard atexit (3) instead.
END