Process Relationships Terminal and Network Logins Process Groups and Sessions Job Control Relationships.

Slides:



Advertisements
Similar presentations
Pseudo Terminals Concept Application APIs. Overview A pseudo terminal (PTY) is a user level program that appears to be a terminal device to another program.
Advertisements

Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process The Process A process is.
15-213, Fall 06 Outline Shell Lab Processes Signals.
Process groups, sessions, controlling terminal, and job control Process relationship: –Parent/child –Same group –Same session.
Essential System Administration 3rd Edition Chapter 2 The Unix Way(Cont.) University Of Palestine.
Lesson 10-Controlling User Processes. Overview Managing and processing processes. Managing jobs. Exiting/quitting when jobs have been stopped.
System Programming Project 2 Due : 4/19...?. Foreground & Background Foreground job Foreground job Only one at moment Only one at moment Having user’s.
1 Introduction to UNIX Ke Liu
Process Relationships Chien-Chung Shen CIS, UD
Shells and Processes Bryce Boe 2012/08/08 CS32, Summer 2012 B.
1 Introduction to UNIX 2 Ke Liu
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
Linux+ Guide to Linux Certification, Second Edition
Process Control in Unix Operating Systems Hebrew University Spring 2004.
Daemon Processes and inetd Superserver
Processes & Daemons Chapter IV / Part III. Commands Internal commands: alias, cd, echo, pwd, time External commands, code is in a file: grep, ls, more.
Fork and Exec Unix Model Tutorial 3. Process Management Model The Unix process management model is split into two distinct operations : 1. The creation.
Carnegie Mellon 1 Processes, Signals, I/O, Shell Lab : Introduction to Computer Systems Recitation 9: 10/21/2013 Tommy Klein Section B.
The Programming Interface. Main Points Creating and managing processes – fork, exec, wait Performing I/O – open, read, write, close Communicating between.
UNIX Processes. The UNIX Process A process is an instance of a program in execution. Created by another parent process as its child. One process can be.
Unix Processes Slides are based upon IBM technical library, Speaking Unix, Part 8: Unix processes Extended System Programming Laboratory (ESPL) CS Department.
Linux in More Detail Shirley Moore CPS5401 August 29,
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
The process concept (section 3.1, 3.3 and demos)  Process: An entity capable of requesting and using computer resources (memory, CPU cycles, files, etc).
Linux+ Guide to Linux Certification, Third Edition
1 Logging in to a UNIX System init ( Process ID 1 created by the kernel at bootstrap ) spawns getty for every terminal device invokes our login shell terminal.
1 Week 2 The Crunchy Shell to the Soft and Chewy Kernel… Sarah Diesburg 8/3/2010 COP4610 / CGS5765.
Managing processes and services. 1. How Linux handles processes 2. Managing running processes 3. Scheduling processes.
The kernel considers each program running on your system to be a process A process lives as it executes, with a lifetime that may be short or long A process.
CE Operating Systems Lecture 10 Processes and process management in Linux.
Agenda  Working with Processes: Purpose Running Programs within same process (execl, execlp, execle, execv, execvp, execve) “Spawning” other process (fork,
EMT 2390L Lecture 5 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
System calls for Process management
Chapter 11 Process Management
Processes Dr. Yingwu Zhu. Process Concept Process – a program in execution – What is not a process? -- program on a disk - a process is an active object,
Concurrent Processes Processes can concurrently run same program. Processes can concurrently run same program. Processes can start other processes. Processes.
Operating Systems Process Creation
What is a Process? u A process is an executable “cradle” in which a program may run u This “cradle” provides an environment in which the program can run,
1 Lecture 6 Introduction to Process Management COP 3353 Introduction to UNIX.
CSCI 330 UNIX and Network Programming Unit XII: Process & Pipe Part 1.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 9 Working.
ACCESS CONTROL. Components of a Process  Address space  Set of data structures within the kernel - process’s address space map - current status - execution.
The Process CIS 370, Fall 2009 CIS UMassD. The notion of a process In UNIX a process is an instance of a program in execution A job or a task Each process.
1 Exceptional Control Flow III. 2 Outline Loading and Running Programs Multitasking, shells Suggested reading 8.4.
System calls for Process management Process creation, termination, waiting.
CSC414 “Introduction to UNIX/ Linux” Lecture 3
Agenda Managing Processes (Jobs) Command Grouping Running jobs in background (bg) Bringing jobs to foreground (fg), Background job status (jobs) Suspending.
PROCESSES We will learn more about: ¨ Multi-user processing and multi −tasking ¨ Multi-user processing and multi −tasking ¨ Process types ¨ Process types.
1 Lecture 19: Unix signals and Terminal management n what is a signal n signal handling u kernel u user n signal generation n signal example usage n terminal.
Dsh: A Devil Shell COMPSCI210 Recitation 14 Sep 2012 Vamsi Thummala.
Unix System Administration Controlling Processes Chapter 5.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
An Introduction to processes R Bigelow. A Unix Process A process in Unix is simple a program The Unix system is made up of a group of processes all interacting.
Process Relationships Chien-Chung Shen CIS/UD
Implementation of a simple shell, xssh
Process relationships
Implementation of a simple shell, xssh (Section 1 version)
Implementation of a simple shell, xssh
Unix Process Management
Fork and Exec Unix Model
The Linux Command Line Chapter 10
Process Control Course code: 10CS62 Prepared by : Department of CSE
Introduction to Linux/UNIX
CHAPTER 13 Processes.
Today’s topic UNIX process relationship and job control
Linux Shell Script Programming
Lab 6: Process Management
Lecture 6 Introduction to Process Management
System Programming: Process Management
Presentation transcript:

Process Relationships Terminal and Network Logins Process Groups and Sessions Job Control Relationships

Terminal Logins Terminals Point to Point connection Local – hard wired Remote – direct connection via modem

Terminal Login Process init reads terminal configuration file /etc/ttys (/etc/inittab for Linux) init process forks and execs getty for each terminal getty opens terminal device for reading and writing and sets up standard file descriptors 0, 1 and 2 getty prompts for username and execs login execle(“/bin/login”, “login”, “-p”, username, (char *) 0, envp);

Terminal Login Process login retrieves encrypted password stored in shadow file using getpwnam function. login calls getpass function to prompt for password. It then encrypts it by calling crypt function and compares result to what it retrieved from the shadow file If not successful, login will exit with status 1 and init will fork a new getty process for that terminal

Terminal Login Process If successful login will Change to user’s home directory (chdir) Change the terminal device ownership to the user (chown) so that we can read/write it Set group IDs (setgid and initgroups) Setup some of the environment variables Set user IDs (setuid) Exec our default shell execl(“/bin/sh”, “-sh”, (char *)0);

Network Logins Unknown, possibly large number of connections. Not practical to fork a getty for each possible one Wait for an incoming network connection, and create a process as needed Pseudo-terminal is a converter acts like a terminal to the rest of the system but can communicate with the network as well

Network Login Process Internet Supervisor – inetd process. When system starts up, init forks a shell that runs commands in /etc/rc. One of those is a command to start the initd process. Once the shell exits, the inetd process is inherited by init inetd listens for TCP/IP connections and forks/execs the appropriate program

Network Login Process In the case of TELNET, inetd forks and execs telnetd telnetd creates the pseudo terminal and forks a child Parent handles network communication Child execs login Parent and child are connected through the pseudo terminal

Process Groups Collection of related processes Each group has a group ID. Like PIDs, these are positive ints pid_t getpgrp(void); pid_t getpgid(pid_t pid); Gets the process group ID of the current process or the specified process

Process Groups Each process group has a leader. The leader of the group is the process that has a PID equal to the PGID int setpgid(pid_t pid, pid_t pgid); Sets the PGID for the process specified by PID If pid is 0, current process is assumed If pgid is 0, value of pid is used setpgid(0,0) commonly used to create a new group

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

Creating A New Session pid_t setsid(void) If process is already a process group leader, returns -1 If process is not already a process group leader A new session is created, and the calling process is its leader A new process group is created with the calling process as its leader Process has no controlling terminal. If it already had one, the connection is broken

Controlling Terminal Sessions can have at most one controlling terminal (usually the terminal or pseudo terminal that we log in from) Session leader that opens the terminal is called the controlling process If the session has a controlling terminal then it has one foreground process group and may have several background process groups Foreground process group receives terminal input SIGINT Ctrl-C SIGQUIT Ctrl-\ SIGTSTP Ctrl-Z Network (or modem) disconnect causes a signal (SIGHUP) to be sent to the controlling process (session leader)

tcgetpgrp, tcsetpgrp and tcgetsid functions pid_t tcgetpgrp(int fd); Returns the process group ID of the foreground process for the terminal open on the given file descriptor int tcsetpgrp(int fd, pid_t pgrp); Instructs the kernel to make the process group indicated by pgrp the foreground process group of the session associated with the controlling terminal fd. The pgrp ID must be a valid process group within the session associated with the terminal on fd. pid_t tcgetsid(int fd); Returns the session id given a file descriptor to the controlling terminal

Job Control Allows us to run multiple process groups (jobs) simultaneously Must be able to control which process is the foreground process and be able to stop and continue processes Job control requires A shell that supports it (Bourne doesn’t) Terminal driver supports it Kernel supports certain signals

Shell Execution of Programs When we type in a command the shell does a fork and exec If it’s a foreground process the parent waits If it’s a background process the parent continues Pipeline – ex: ls | grep “hello” Process order depends on shell Often last command is forked first

Examples ps –o pid,ppid,pgid,sid,tpgid,comm PID PPID PGID SID TPGID COMMAND bash ps

Examples ps –o pid,ppid,pgid,sid,tpgid,comm & PID PPID PGID SID TPGID COMMAND bash ps

Examples ps –o pid,ppid,pgid,sid,tpgid,comm | cat PID PPID PGID SID TPGID COMMAND bash ps cat

Examples ps –o pid,ppid,pgid,sid,tpgid,comm | cat& PID PPID PGID SID TPGID COMMAND bash ps cat