On_exit () function instructions

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.