The relationship between Linux processes

Source: Internet
Author: User

The Linux process has a certain relationship with each other. For example, in the Linux process Foundation, we see that each process has a parent process, and all processes take the init process as the root, forming a tree structure. Here we explain the process groups and sessions in order to manage the process in a richer way.

1. Group of processes (process group)

Each process belongs to a process group, and each process group can contain multiple processes. The process group will have a process group leadership process (processes group leader), and the leader process's PID (the PID sees the Linux process base) becomes the process group ID (processes group ID, pgid) to identify the process group.

$ps-O Pid,pgid,ppid,comm | Cat

PID Pgid PPID COMMAND
17763 17763 17751 Bash
18534 18534 17763 PS
18535 18534 17763 Cat

The PID is the id,pgid of the process itself as the ID of the process group in which the process is located, ppid the process's parent process ID. From the results above, we can extrapolate the following relationship:

The arrows in the diagram indicate that the parent process produces a subprocess through the fork and exec mechanisms. Both PS and cat are child processes of bash. The PID of the process group's lead process becomes the process group ID. The leadership process can be terminated first. The process group still exists and holds the same pgid until the last process in the process group is terminated.

One of the important reasons why we classify processes as process groups is that we can send signals to a process group. All processes in the process group will receive the signal. We will discuss this in depth in the next section.

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.