100 likes | 246 Views
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
E N D
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
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
Process Group • Process has PID and belongs to a group • A process groupis a collection of processes associated with the same job, that can receive signals from the same terminal • Process group ID #include <unistd.h> pid_tgetpgrp(void); pid_tgetpgid(pid_tpid); • getpgid(0) == getpgrp()(calling process) • Each process group has a leader, whose process group ID == its PID
Sessions • A session is a collection of one or more process groups • proc1 | proc2 &proc3 | proc4 | proc5
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 foregroundprocess group
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