Process Environment Details (ii)---process termination and atexit functions

Source: Internet
Author: User

process termination can be divided into normal process termination and process exception termination.
    • The normal termination of a process is as follows:
      • The main function returns
      • Call the Exit function
      • Call the _exit or _exit function
      • The last thread returns from the startup code
      • The last thread calls Pthread_exit
    • There are several situations where the process terminates abnormally:
      • Call the Abort function
      • Process received signal termination
      • The last thread responds to a cancellation request
========================================================the difference between the Exit function and the _exit/_exit function is:The exit function is not immediately entered into the kernel state, but it is preceded by a number of termination handlers (functions registered with the Atexit function), as well as forcing the flush of all user buffers and so on. The _exit and _exit functions are immediately entered into the kernel state to perform kernel processing, and the user buffer is not processed. The _exit or _exit function is also encapsulated in the Exit function. using the return keyword in the main function is identical to calling the Exit function. ========================================================the function of the Atexit function is to register the function, which will be executed when calling the Exit function or using the return keyword in the main function. The order of execution and the order of the calls is reversed. function Prototypes:function Parameters:
    • Function: Functions pointer
return Value:
    • return 0 upon successful invocation
    • Return non 0 if call fails

Process Environment Details (ii)---process termination and atexit functions

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.