Precautions in Linux

Source: Internet
Author: User

(1) The difference between exit () and _ exit (): _ exit () directly stops the process, clears the memory space used by the Eliminator, and destroys various data structures in the kernel.

Before calling the exit system, the exit () function should check the file opening status, write the content in the File Buffer back to the file, and clear the I/O buffer (this function is recommended)

(2) waitpid

# Include <sys/types. h>

# Include <sys/Wait. H>

Pid_t waitpid (pid_t PID, int * status, int options );

The values of PID are different, with different meanings:

When the PID is greater than 0, only the child process whose process id = PID is waiting, no matter how many other child processes have been launched, as long as the specified child process has not ended, waitpid will keep waiting;

When pid =-1, wait for any sub-process to exit without any restrictions. At this time, waitpid and wait work the same way;

When pid = 0, wait for any sub-process in the same process group. If the sub-process has been added to another process group, waitpid will not ignore it;

PID <-1, wait for any sub-process in a specified process group, the ID of this process group is equal to the absolute value of PID

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.