Process groups, jobs, session-related concepts

Source: Internet
Author: User

Inter-process relationships: synchronous, mutex, and others.

Shell Terminal: You can run a foreground job and any number of background jobs, which is called job control.

Process Group : each process belongs to a process group in addition to a process ID. A process group is a collection of one or more processes.
Typically, they are associated with the same job and can receive various signals from the same terminal.

Note: as long as a process exists in a process group, the process group exists, regardless of whether its leader process terminates

job :shell Job (

Shell job and any number of background jobs, which is called job control.

The difference between a job and a process group: If a process in the job has created a child process, the child process does not belong to the job.

A session is a collection of one or more process groups.

A session can have a control terminal. the first process of establishing a session connected to a control terminal is called the control process.
Multiple process groups in a session can be divided into one foreground process group and one or more background process groups. Therefore , a session should include the control process (session first process), a foreground process group, and any background process group.

The kernel sends a corresponding signal to all processes in the foreground process group.

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7F/CC/wKioL1ctlmXBsYjFAAD412wp83Y281.png "title=" QQ Figure 53.png "alt=" Wkiol1ctlmxbsyjfaad412wp83y281.png "/>

BG% 1, or BG 1: Put the front desk work backstage.

FG% 1, or FG 1: Put background jobs in the foreground.

How Bash Works: Identify commands (whether justified), fork sub-processes, child Process Execution code (bash background)

Terminal : Open terminal, set up a session, bash is the foreground, there are very many jobs in the background.

InUnixIn the systemUseThe user logs into the system via the terminal and gets aShellProcess,This terminal becomesShellControl of the processTerminal(controlling Terminal),The control terminal is saved inpcb We know fork will replicate pcb information ,shell The terminal is also the control terminal of other processes initiated by the process.

Note: standard input, standard output, and standard error outputs for each process point to the control terminal when no redirection is in progress

#include <stdio.h> #include <unistd.h>int main () {printf ("pid:%d\n", Getpid ());    printf ("In:%s\n", Ttyname (0));    printf ("Out:%s\n", Ttyname (1)); printf ("Err:%s\n", Ttyname (2));}

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/CE/wKiom1ctkkexIUcYAAAR7s6rE68360.png "title=" QQ picture 20160507145655.png "alt=" Wkiom1ctkkexiucyaaar7s6re68360.png "/>

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7F/CE/wKiom1ctlVHQutpjAAC6oonK4v4886.png "title=" QQ picture 20160507150931.png "alt=" Wkiom1ctlvhqutpjaac6oonk4v4886.png "/>

This article is from the "Small Stop" blog, please be sure to keep this source http://10541556.blog.51cto.com/10531556/1771006

Process groups, jobs, session-related concepts

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.