Process Control (eight)---child process-terminated state-related macros

Source: Internet
Author: User
Tags exit in terminates
As mentioned in the previous notes, the parent process can get to its terminating state either through the wait function or the WAITPID function, regardless of whether the child process terminates normally or terminates abnormally. However, the information obtained by the normal termination and the abnormal termination of the parent process is different, and the parent process receives the parameter of exit in the child process at normal termination, and the parent process receives the signal number value that causes the child process to terminate abnormally when the exception terminates. the normal termination of the status value returned to the parent process and the signal value passed to the parent process at the end of the exception is stored on the different bits of the memory that the wait or Waitpid function's parameter status points to. If the parent process wants to know whether the child process is terminating normally or terminating abnormally, it can be determined by determining if there is a value on the corresponding bit. The Linux system provides several macros to implement:
  • wifexited (status): Test whether it is a normal exit
    • Wexitstatus (status): Gets the terminating status value of the child process
  • Wifsignaled (status): Test for abnormal exit
    • Wtermsig (status): Gets the signal number value that caused the child process to terminate abnormally

Process Control (eight)---child process-terminated state-related macros

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.