process relationships chien-chung shen cis, ud [email protected]

9
Process Relationships Chien-Chung Shen CIS, UD [email protected]

Upload: warren-short

Post on 17-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Process Relationships Chien-Chung Shen CIS, UD cshen@cis.udel.edu

Process Relationships

Chien-Chung ShenCIS, UD

[email protected]

Page 2: Process Relationships Chien-Chung Shen CIS, UD cshen@cis.udel.edu

Introduction

• Every process has a parent process (init is its own parent)

• The parent is notified when the child terminates; parent obtains the child’s exit status

• Process group• Session• Login shell and other (child) processes• Signal

Page 3: Process Relationships Chien-Chung Shen CIS, UD cshen@cis.udel.edu

Terminal Login

• Dumb terminal connected to a host with hard-wired connections: local (directly connected) or remote (via a modem)

• Login came through a terminal device driver in the kernel a fixed # of terminal devices and hence logins

• GUI and windowing systems “terminal windows” emulate character-based terminals

Page 4: Process Relationships Chien-Chung Shen CIS, UD cshen@cis.udel.edu

Process Group

• Process has PID and belongs to a group• A process group is a collection of processes

associated with the same job, that can receive signals from the same terminal

• Process group ID #include <unistd.h> pid_t getpgrp(void); pid_t getpgid(pid_t pid);

• getpgid(0) == getpgrp()(calling process)• Each process group has a leader, whose

process group ID == its PID

Page 5: Process Relationships Chien-Chung Shen CIS, UD cshen@cis.udel.edu

Sessions

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

• proc1 | proc2 &proc3 | proc4 | proc5

Page 6: Process Relationships Chien-Chung Shen CIS, UD cshen@cis.udel.edu

Controlling Terminal

• A session can have a single controlling terminal - the terminal device (a terminal login) or pseudo terminal device (a network login) on which we log in

• The session leader that establishes the connection to the controlling terminal is the controlling process

• The process groups within a session can be divided into a single foreground process group and one or more background process groups

• If a session has a controlling terminal, it has a single foreground process group and all other process groups in the session are background process groups

• Whenever press terminal’s interrupt key (^C), the interrupt signal is sent to all processes in the foreground process group

Page 7: Process Relationships Chien-Chung Shen CIS, UD cshen@cis.udel.edu

Controlling Terminal

Page 8: Process Relationships Chien-Chung Shen CIS, UD cshen@cis.udel.edu

Job Control

• Start multiple jobs (groups of processes) from a single terminal and to control which jobs can access the terminal and which jobs are run in the background

• A job is simply a collection of processes, often a pipeline of processes

• vi main.c // starts a job of one process in the foreground• pr *.c | lpr &make all &

// start two jobs in the background

Page 9: Process Relationships Chien-Chung Shen CIS, UD cshen@cis.udel.edu

Job Control