APUE Reading Notes-Chapter 1 process relationship

Source: Internet
Author: User

Chapter 4 Process relationship
9.1 Introduction
* Each process has a parent process (the initial kernel process has no parent process, or its parent process is itself)
* When a child process is terminated, the parent process is notified and can exit the child process.

9.2 terminal Login
* The terminal can be a character-based terminal, a simple simulation character-based graphical terminal, or a graphical terminal that runs the window system.
* The system administrator creates a file named/etc/ttys. Each terminal device has a row, indicating the device name and parameters passed to the getty program. When the system performs a UDF, the kernel creates a process with a process ID of 1, that is, the init process. The init process enters the multi-user State. The init process reads the file/etc/ttys. For each terminal device that is allowed to log on, init calls fork once, and the child process generated by it executes the (exec) getty program.

9.3 network login
* The main (physical) Difference between logging on to the system through a serial terminal and logging on to the system through the network is that when logging on through the network, the connection between the host box computers is not a point-to-point connection. In this case, login is only an available service, which is of the same nature as other network services (such as FTP or SMTP ).

9.4 Process Group
* In addition to a process ID, each process also belongs to a process group.

9.5 sessions
* A session is a collection of one or more Process Groups. Usually, several processes are programmed by the shell Pipe Line.

9.6 control terminal
* Sometimes, the program must interact with the control terminal regardless of whether the standard input or standard output is redirected. The method to ensure that the program can read and write the control terminal is to open the file/dev/tty. In the kernel, this special file is used to control the terminal's meaning. Naturally, if the program has no control terminal, opening the device will fail.

9.7 tcgetpgrp, rcsetpgrp, and tcgetsid Functions
* The tcgetpgrp function returns the process group ID of the foreground process group.
* If a process has a control terminal, the process can call tcsetpgrp to set the foreground Process Group ID to pgrpid.
* The file descriptor for controlling TTY is provided. The application that calls tcgetsid can obtain the ID of the Process Group of the first process of the session.

9.8 job control
* Job control allows you to start multiple jobs (Process Groups) on a terminal. It supports which jobs can access the terminal and which jobs are running in the background. Job control requires support in the following three forms:
(1) shell supporting job control
(2) The Terminal Driver in the kernel must support job control.
(3) The kernel must support some job control signals.

9.9 shell execution Program
* The Linux shell runs two processes on the frontend in a pipeline. Both processes are in a new process group, which is a foreground process group. Shell is the parent process of two processes.

9.10 orphan Process Group
* Orphaned process group is defined as: the parent process of each member in the group is either a member of the group or a member of the session of the group.
* Another description of an orphan process group is that a process group is not an orphan process group. A process exists in this group and its parent process is in another group of the same session.

9.11 FreeBSD implementation
* Session structure: each session is assigned a session structure.
* Tty structure: each terminal device and each Pseudo Terminal device are allocated in the kernel.
* Pgrp structure: contains information about a specific process group.
* Proc structure: contains all information about a process.
* Vnode structure: this structure is allocated when the control terminal device is enabled. Process pairs/dev/tty all references are in the vnode structure. The actual I node is part of the v node.

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.