Linux Process Group session control terminal

Source: Internet
Author: User

In the linux Process Group session control terminal, a process can create sub-processes by calling fork (). These processes can constitute a process group. Www.2cto.com process group ----------------------------------------------- a process group is a collection of one or more processes. Each process group has a process called the leader. The leader process is the process whose process ID (pid) is equal to the Process Group ID (gid) (that is, the process group number is equal to the process Number of the leader ). The process group concept has many purposes. The most common is that we send a termination signal (Ctrl-C) to the foreground program execution on the terminal while terminating all processes in the process group. (1 ). A command line on Shell forms a process group (2 ). each process belongs to a process group (3 ). each process group has a lead process (group leader) (4 ). the lifecycle of a process group ends with the last process in the group or ends with another process group (5 ). getpgrp: Get the process group id, that is, the pid (6) of the lead process ). foreground process group and background process group (7 ). process A (assuming the process is the leader) and its sub-process B belong to the same process group. Their process group number (task_struct.gid) is the process Number of process A (. pid) Session www.2cto.com --------------------------------------------- a Session is a collection of one or more Process Groups. Generally, all programs executed after a user logs on belong to a Session period, while the shell logon is the first Session process (Session leader ), in addition, it uses the Controlling Terminal. Therefore, the first process in the session is also called the Controlling process ). When we exit logout, all processes that belong to this session will be terminated. (1 ). one login forms a session (2 ). A session can contain multiple process groups, but only one foreground process group can exist. (3 ). setsid () creates a new session. If the process that calls this function is not the leading process of the Process Group, this function can create a new session. after setsid () is called, The Calling process becomes the lead process of the new session. control terminal ------------------------------------------- (1) After the lead process of a session opens a terminal, the terminal becomes the control terminal of the session (SVR4/Linux) (2) the session lead process established with the control terminal is called the control process (3) one session can only have one control terminal (4) the input and signal generated on the control terminal will be sent to all processes in the foreground Process Group of the session (5) when the connection on the terminal is disconnected (such as network disconnection or Modem disconnection ), the pending signal will be sent to the control process (session leader)

Related Article

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.