CIS 90 - Lesson 10 Lesson Module Status Slides – draft Properties - done Flash cards – No-stress quiz – done Web calendar summary – done Web book pages.

Slides:



Advertisements
Similar presentations
June 1, 1999Foreground/Background Processing1 Introduction to UNIX H. Foreground/Background Processing.
Advertisements

Week Fourteen Agenda Announcements Final Exam True/False -100 questions (1 point per question) Multiple Choice - 40 questions (2 points per question)
Using tcpdump. tcpdump is a powerful tool that allows us to sniff network packets and make some statistical analysis out of those dumps. tcpdump operates.
2.3 InterProcess Communication (IPC) Part A. IPC methods 1. Signals 2. Mutex (MUTual EXclusion) 3. Semaphores 4. Shared memory 5. Memory mapped files.
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.
Processes and Job Control. Foreground and Background (1)  Unix is a multi-tasking operating system –some of these tasks are being done by other users.
CSCI 330 T HE UNIX S YSTEM Shell Job Control. T ODAY ’ S CLASS Unix is multi-user, multi-process OS Shell features to control jobs Unix utilities to manage.
Introduction to Unix – CS 21 Lecture 10. Lecture Overview Midterm questions Jobs and processes description The foreground and background Controlling jobs.
Lesson 10-Controlling User Processes. Overview Managing and processing processes. Managing jobs. Exiting/quitting when jobs have been stopped.
1 © 2001 John Urrutia. All rights reserved. Chapter 5 The Shell Overview.
CIS 90 - Lesson 11 Lesson Module Status Slides – Properties - Flash cards – No-stress quiz – Web calendar summary – Web book pages – Commands – Lab – .
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
Linux+ Guide to Linux Certification, Second Edition
Process Process: the UNIX abstraction of a stand-along computer that manages resources (memory, CPU, I/O resources) comprising a running program. Processes.
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
CS 497C – Introduction to UNIX Lecture 27: - The Process Chin-Chih Chang
CSc 352 Signal Handling in Unix Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
Process states inWindows 2000 and Linux Module 2.1.
Chapter 4 The UNIX Shells (Bourne shell, Korn shell, C shell)‏ Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice.
Xuan Guo Chapter 4 The UNIX Shells Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, Original Notes.
5 UNIX Processes. Introduction  Processes  How to list them  How to terminate them  Process priorities  Scheduling jobs  Signals.
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 System Administration Handbook Chapter 4. Controlling Processes 3 rd Edition Evi Nemeth et al. Li Song CMSC691X Summer 2002.
Operating Systems Yasir Kiani. 22-Sep Agenda for Today Review of previous lecture Process management commands: bg, fg, ^Z, jobs, ^C, kill Thread.
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).
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
Linux+ Guide to Linux Certification, Third Edition
CIS 90 - Lesson 11 Lesson Module Status Slides – draft Properties - done Flash cards – 1 st minute quiz – done Web calendar summary – done Web book pages.
Va-scanCopyright 2002, Marchany Unit 7 – Solaris Process Control Randy Marchany VA Tech Computing Center.
Managing processes and services. 1. How Linux handles processes 2. Managing running processes 3. Scheduling processes.
Linux+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
RH030 Linux Computing Essentials
SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to UNIX / Linux - 8 Dr. Jerry Shiao, Silicon Valley University.
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.
CIS 90 - Lesson 10 Lesson Module Status Slides – draft Properties - done Flash cards – No-stress quiz – done Web calendar summary – done Web book pages.
Hands On UNIX II Dorcas Muthoni. Processes A running instance of a program is called a "process" Identified by a numeric process id (pid)‏  unique while.
Week Fourteen Agenda Announcements Final Exam True/False -100 questions (1 point per question) Multiple Choice - 40 questions (2 points per question)
Agenda  Working with Processes: Purpose Running Programs within same process (execl, execlp, execle, execv, execvp, execve) “Spawning” other process (fork,
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. C H A P T E R S I X Exception Handling.
Unix Process Model Simple and powerful primitives for process creation and initialization. fork syscall creates a child process as (initially) a clone.
Scis.regis.edu ● CS 468: Advanced UNIX Class 5 Dr. Jesús Borrego Regis University 1.
Week Fourteen Agenda Announcements Final Exam True/False -100 questions (1 point per question) Multiple Choice - 40 questions (2 points per question)
Linux+ Guide to Linux Certification Chapter Eleven Managing Linux Processes.
Concurrent Processes Processes can concurrently run same program. Processes can concurrently run same program. Processes can start other processes. Processes.
Signals and Signal Processing CIS 370 Lab 7 Umass Dartmouth.
Signals (Chap 10 in the book “Advanced Programming in the UNIX Environment”) Acknowledgement : Prof. Y. Moon at Kangwon Nat’l Univ.
UNIX Signals * POSIX-Defined Signals * Signaling Processes * Signal Mask * sigaction * kill and sigaction * alarm * Interval Timers * POSIX.1b Timers *
Interprocess Communication Mechanisms. IPC Signals Pipes System V IPC.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
© 숙대 창병모 1 제 10 장 신호 (Signal). © 숙대 창병모 2 Contents 1. Signal Concepts 2. signal() 3. Interrupted System Calls 4. kill() /raise() 5. alarm() pause() 6.
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.
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop VI Scheduling & Process Management Professional.
ACCESS CONTROL. Components of a Process  Address space  Set of data structures within the kernel - process’s address space map - current status - execution.
S -1 Processes. S -2 wait and waitpid (11.2) Recall from a previous slide: pid_t wait( int *status ) wait() can: (a) block; (b) return with status; (c)
CSC414 “Introduction to UNIX/ Linux” Lecture 3
Unix System Administration Controlling Processes Chapter 5.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
Processes Todd Kelley CST8207 – Todd Kelley1.
Process Relationships Chien-Chung Shen CIS/UD
UNIX signals.
...looking a bit closer under the hood
Hands On UNIX AfNOG 2010 Kigali, Rwanda
Hands On UNIX AfNOG X Cairo, Egypt
CSC Advanced Unix Programming, Fall 2015
Operating Systems Lecture 12.
CSC 140: Introduction to IT
Inter-Process Communication ENCE 360
Controlling Processes
Signals.
Presentation transcript:

CIS 90 - Lesson 10 Lesson Module Status Slides – draft Properties - done Flash cards – No-stress quiz – done Web calendar summary – done Web book pages – done Commands – done Lab – done Supplies () - na Class PC's – na Scripts () – done

CIS 90 - Lesson 10 ObjectivesAgenda Know the process life cycle Interpret ps command output Run or schedule jobs to run in the background Send signals to processes Configure process load balancing Questions from last week Housekeeping Process definition Process lifecycle Process information Job control Signals Load balancing Test #2 Wrap up UNIX Processes

CIS 90 - Lesson 10 Previous material and assignment 1.Questions on previous material? 2.Questions regarding the test tonight? FYI - set-x, set +x to show the command line expansion performed by bash Note: Single and double quotes and metacharacters.

CIS 90 - Lesson 10 FYI set –x, set +x /home/cis90/roddyduk $ find. -name "treat*" + find. -name 'treat*'./.mozilla/extensions/treat3./.mozilla/plugins/treat4./.mozilla/treat2./bin/treat5 find:./Hidden: Permission denied./poems/treat6./treat1 find:./testdir: Permission denied ++ echo -ne /home/cis90/roddyduk $ find. -name 'treat*' + find. -name 'treat*'./.mozilla/extensions/treat3./.mozilla/plugins/treat4./.mozilla/treat2./bin/treat5 find:./Hidden: Permission denied./poems/treat6./treat1 find:./testdir: Permission denied ++ echo -ne /home/cis90/roddyduk $ find. -name trea* + find. -name treat1 find:./Hidden: Permission denied./treat1 find:./testdir: Permission denied ++ echo -ne /home/cis90/roddyduk $ /home/cis90/roddyduk $ find. -name '$LOGNAME' + find. -name '$LOGNAME' find:./Hidden: Permission denied find:./testdir: Permission denied ++ echo -ne /home/cis90/roddyduk $ find. -name "$LOGNAME" + find. -name roddyduk find:./Hidden: Permission denied./roddyduk find:./testdir: Permission denied ++ echo -ne /home/cis90/roddyduk $ set –x shows you the actual expansion done by bash and what is passed in to the process

find command CIS 90 - Lesson 8 ~]$ find. -type d -name "[BSYA]*" find:./Hidden: Permission denied./poems/Blake./poems/Shakespeare./poems/Yeats./poems/Anon ~]$ Find all directories starting in my home directory that start with a capital B, S, Y or A. ~]$ find. -name "\*town\*" find:./Hidden: Permission denied ~]$ find. -name "*town*" find:./Hidden: Permission denied./edits/small_town./edits/better_town ~]$ Find all files starting in my home directory that contain town

CIS 90 - Lesson 10 Process Definition

CIS 90 - Lesson 10 Definition of a process A process is a program that has been copied (loaded) into memory by the kernel and is either running (executing instructions) or waiting to run. The CPU executes the instructions in RAM RAM (Random Access Memory) contains the instructions

/home/cis90/roddyduk $cmd CIS 90 - Lesson 10 Program to process cmd stderr stdin stdout Options: NA Args: NA A process is a program that has been loaded into memory and is either running (executing instructions) or waiting to run

/home/cis90/roddyduk $ sort duke benji star homer benji duke homer star /home/cis90/roddyduk $ CIS 90 - Lesson 10 Example program to process: sort command sort stderr stdin stdout Options: NA Args: NA duke benji star homer benji duke homer star ctrl D /dev/pts/0 A command like sort is a program when it is stored on the drive. It is a process when it is copied to memory by the kernel and either running or waiting to run.

CIS 90 - Lesson 10 Most programs are written in the C language The C compiler translates the C code into binary machine code instructions the CPU can execute.

CIS 90 - Lesson 10 A command like sort is a program when it is stored on the drive. It is a process when it is copied to memory by the kernel and either running or waiting to run by the CPU Example program to process: sort command

CIS 90 - Lesson 10 Definition of a process A process is a program that has been copied (loaded) into memory by the kernel and is either running (executing instructions) or waiting to run. The CPU executes the instructions in RAM RAM (Random Access Memory) contains the instructions

CIS 90 - Lesson 10 Process Life Cycle

Process Lifecycle CIS 90 - Lesson 10 / PID: 501 PPID: 250 bash PID: 582 PPID: 501 PID: 582 PPID: 501 PID: 501 PPID: 250 PID: 501 PPID: 250 bash fork() X exec() wait() exit() bash cmd bash

Process Lifecycle CIS 90 - Lesson 10 / PID: 501 PPID: 250 bash PID: 582 PPID: 501 PID: 582 PPID: 501 PID: 501 PPID: 250 PID: 501 PPID: 250 bash X exec() wait() exit() bash cmd bash 1) When a program is loaded into memory a new process must be created. This is done by the parent process (bash) making a copy of itself using the fork system call. The new child process is a duplicate of the parent but it has a different PID.

Process Lifecycle CIS 90 - Lesson 10 / PID: 501 PPID: 250 bash PID: 582 PPID: 501 PID: 582 PPID: 501 PID: 501 PPID: 250 PID: 501 PPID: 250 bash fork() X exit() bash cmd bash 2) An exec system call is issued to overlay the child process with the instructions of the requested command. The new instructions then are executed. The parent process issues the wait system call and goes to sleep.

Process Lifecycle CIS 90 - Lesson 10 / PID: 501 PPID: 250 bash PID: 582 PPID: 501 PID: 582 PPID: 501 PID: 501 PPID: 250 PID: 501 PPID: 250 bash fork() X exec() wait() bash cmd bash 3) When the child process finishes executing the instructions it issues the exit system call. At this point it gives up all its resources becomes a zombie. The parent is woken up and once the parent has informed the kernel it has finished working with the child, the child process is killed and its removed from the process table.

Process Lifecycle CIS 90 - Lesson 10 / PID: 501 PPID: 250 bash PID: 582 PPID: 501 PID: 582 PPID: 501 PID: 501 PPID: 250 PID: 501 PPID: 250 bash fork() X exec() wait() bash cmd bash 3) If the parent process were to die before the child, the zombie will become an orphan. Fortunately the init process will adopt any orphaned zombies.

CIS 90 - Lesson 10 Process Information

CIS 90 - Lesson 10 Process Information InformationDescription PIDProcess Identification Number, a unique number identifying the process PPIDParent PID, the PID of the parent process (like … in the file hierarchy) UIDThe user running the process TTYThe terminal that the process's stdin and stdout are connected to SThe status of the process: S=Sleeping, R=Running, T=Stopped, Z=Zombie PRIProcess priority SZProcess size CMDThe name of the process (the command being run) CThe CPU utilization of the process WCHANWaiting channel (name of kernel function in which the process is sleeping) FFlags (1=forked but didn't exit, 4=used superuser privileges) TIMECumulative CPU time NINice value Just a few of types of information kept on a process. Use man ps to see a lot more.

CIS 90 - Lesson 10 Process Information Show just my processes Show all processes with a tty

CIS 90 - Lesson 10 Process Information -a show processes with a terminal x option shows full commands being run and states (most are asleep). I'm using two Putty sessions, in one session I have the man page open for ps, the other I'm issuing ps commands

CIS 90 - Lesson 10 Process Information Use the u option to look at processes owned by a specific user

CIS 90 - Lesson 10 Process Information Use the u option to look at processes owned by a specific user

CIS 90 - Lesson 10 Process Information Use –l for additional options

CIS 90 - Lesson 10 Process Information

CIS 90 - Lesson 10 Process Information root Sep10 ? 00:00:00 [ata/1] root Sep10 ? 00:00:00 [ata_aux] root Sep10 ? 00:00:00 [scsi_eh_0] root Sep10 ? 00:00:00 [scsi_eh_1] root Sep10 ? 00:01:25 [kjournald] root Sep10 ? 00:00:00 [kauditd] root Sep10 ? 00:00:00 /sbin/udevd -d root Sep10 ? 00:00:01 [kedac] root Sep10 ? 00:00:00 [kmpathd/0] root Sep10 ? 00:00:00 [kmpathd/1] root Sep10 ? 00:00:05 /usr/sbin/restorecond root Sep10 ? 00:00:11 auditd root Sep10 ? 00:00:05 /sbin/audispd root Sep10 ? 00:00:23 syslogd -m 0 root Sep10 ? 00:00:00 klogd -x root Sep10 ? 00:00:20 mcstransd rpc Sep10 ? 00:00:00 portmap root Sep10 ? 00:01:18 /usr/bin/python -E /usr/sbin/setroub rpcuser Sep10 ? 00:00:00 rpc.statd root Sep10 ? 00:00:00 rpc.idmapd root Sep10 ? 00:00:00 /usr/bin/vmnet-bridge -d /var/run/vm root Sep10 ? 00:00:00 /usr/bin/vmnet-natd -d /var/run/vmne dbus Sep10 ? 00:00:15 dbus-daemon --system root Sep10 ? 00:00:51 pcscd root Sep10 ? 00:00:00 /usr/bin/hidd --server root Sep10 ? 00:00:02 automount

CIS 90 - Lesson 10 Process Information root Sep10 ? 00:00:00./hpiod root Sep10 ? 00:00:00 python./hpssd.py root Sep10 ? 00:00:00 cupsd root Sep10 ? 00:00:11 /usr/sbin/sshd root Sep10 ? 00:00:01 sendmail: accepting connections smmsp Sep10 ? 00:00:00 sendmail: Queue for root Sep10 ? 00:00:00 crond xfs Sep10 ? 00:00:00 xfs -droppriv -daemon root Sep10 ? 00:00:00 /usr/sbin/atd root Sep10 ? 00:00:00 rhnsd --interval 240 root Sep10 ? 00:01:33 /usr/bin/python -tt /usr/sbin/yum-up root Sep10 ? 00:00:00 /usr/libexec/gam_server root Sep10 ? 00:00:00 /usr/bin/vmnet-netifup -d /var/run/v root Sep10 ? 00:00:00 /usr/bin/vmnet-netifup -d /var/run/v root Sep10 ? 00:00:00 /usr/bin/vmnet-netifup -d /var/run/v root Sep10 ? 00:00:00 /usr/bin/vmnet-dhcpd -cf /etc/vmware root Sep10 ? 00:00:00 /usr/bin/vmnet-dhcpd -cf /etc/vmware root Sep10 ? 00:00:00 /usr/bin/vmnet-dhcpd -cf /etc/vmware Sep10 ? 00:00:01 hald root Sep10 ? 00:00:00 hald-runner Sep10 ? 00:00:00 hald-addon-acpi: listening on acpid Sep10 ? 00:00:00 hald-addon-keyboard: listening on /d Sep10 ? 00:00:00 hald-addon-keyboard: listening on /d root Sep10 ? 00:02:46 hald-addon-storage: polling /dev/hda root Sep10 ? 00:00:00 /usr/sbin/smartd -q never root Sep10 tty2 00:00:00 /sbin/mingetty tty2

CIS 90 - Lesson 10 Process Information root Sep10 tty3 00:00:00 /sbin/mingetty tty3 root :19 ? 00:00:00 sshd: rsimms [priv] rsimms :19 ? 00:00:00 sshd: rsimms :19 pts/0 00:00:00 -bash root :14 ? 00:00:00 sshd: valdemar [priv] valdemar :14 ? 00:00:00 sshd: valdemar :14 pts/5 00:00:00 -bash rsimms :36 pts/0 00:00:00 man ps rsimms :36 pts/0 00:00:00 sh -c (cd /usr/share/man && (echo ". rsimms :36 pts/0 00:00:00 sh -c (cd /usr/share/man && (echo ". rsimms :36 pts/0 00:00:00 /usr/bin/less -is root :37 ? 00:00:00 sshd: rsimms [priv] rsimms :37 ? 00:00:00 sshd: rsimms :37 pts/6 00:00:00 -bash root :07 ? 00:00:00 sshd: dymesdia [priv] dymesdia :08 ? 00:00:00 sshd: dymesdia :08 pts/1 00:00:00 -bash rsimms :15 pts/6 00:00:00 ps -ef lyonsrob Oct01 ? 00:00:00 SCREEN lyonsrob Oct01 pts/3 00:00:00 /bin/bash root Oct15 tty1 00:00:00 /sbin/mingetty tty1 ~]$

CIS 90 - Lesson 10 Job Control

CIS 90 - Lesson 10 Job Control A feature of the bash shell Foreground processes Processes that receive their input and write their output to the terminal. The parent shell waits on these processes to die. Background Processes Processes that do not get their input from a user keyboard. The parent shell does not wait on these processes; it re-prompts the user.

CIS 90 - Lesson 10 Job Control A feature of the bash shell Ctrl-Z or Ctrl-F (SIGTSTP) Stops a foreground process bg resumes the currently suspended process running in the foreground

CIS 90 - Lesson 10 Job Control A feature of the bash shell Ctrl-Z or Ctrl-F (SIGTSTP) Stops (suspends) a foreground process /home/cis90/roddyduk $ stty -a speed baud; rows 26; columns 78; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ; eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^F; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; ~]$ stty -a speed baud; rows 39; columns 84; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ; eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;

CIS 90 - Lesson 10 Job Control A feature of the bash shell Ctrl-Z or Ctrl-F (SIGTSTP) Stops (suspends) a foreground process ctrl-Z is tapped while find is running PID 7587 is stopped

CIS 90 - Lesson 10 Job Control A feature of the bash shell bg Starts the currently suspended process running in the foreground PID 7587 is gone bg resumes the find command and finishes

CIS 90 - Lesson 10 Job Control A feature of the bash shell PID 7728 is stopped Ctlr-Z is tapped which stops the sleep command Ctrl-Z or Ctrl-F (SIGTSTP) Stops (suspends) a foreground process

CIS 90 - Lesson 10 Job Control A feature of the bash shell bg Starts the currently suspended process running in the foreground PID 7728 is gone bg resumes the sleep command

CIS 90 - Lesson 10 Job Control A feature of the bash shell & Append to a command to run it in the background fg Brings the most recent background process to the foreground jobs Lists all background jobs

CIS 90 - Lesson 10 Job Control A feature of the bash shell After fg, sleep now runs in the foreground. The prompt is gone. Need to wait until sleep finishes for prompt to return. The & has sleep run in the background and jobs shows the shows it as the one and only background job & is often used when running GUI tools like Firefox or Wireshark from the command line and you want to keep using the terminal for more commands while those applications run.

CIS 90 - Lesson 10 Signals

CIS 90 - Lesson 10 Signals are asynchronous messages sent to processes They can result in one of three courses of action: 1.be ignored, 2.default action (die) 3.execute some predefined function. Signals are sent: Using the kill command: $ kill -# PID Where # is the signal number and PID is the process id. if no number is specified, SIGTERM is sent. Using special keystrokes limited to just a few signals Use kill –l to see all signals Signals

CIS 90 - Lesson 10 Signals

CIS 90 - Lesson 10 Signals Signals are asynchronous messages sent to processes Running process getting a signal stdin stdout stderr Asynchronous means it can happen at any time

CIS 90 - Lesson 10 Signals Running process gets a signal Signals are asynchronous messages sent to processes stdin stdout stderr

CIS 90 - Lesson 10 Use kill –l to see all signals SIGHUP1Hangup (POSIX) SIGINT2Terminal interrupt (ANSI) Ctrl-C SIGQUIT3Terminal quit (POSIX) Ctrl-\ SIGILL4Illegal instruction (ANSI) SIGTRAP5Trace trap (POSIX) SIGIOT6IOT Trap (4.2 BSD) SIGBUS7BUS error (4.2 BSD) SIGFPE8Floating point exception (ANSI) SIGKILL9Kill (can't be caught or ignored) (POSIX) SIGUSR110User defined signal 1 (POSIX) SIGSEGV11Invalid memory segment access (ANSI) SIGUSR212User defined signal 2 (POSIX) SIGPIPE13Write on a pipe with no reader, Broken pipe (POSIX) SIGALRM14Alarm clock (POSIX) SIGTERM15Termination (ANSI) Signals

CIS 90 - Lesson 10 Signals Use kill –l to see all signals SIGSTKFLT16Stack fault SIGCHLD17Child process has stopped or exited, changed (POSIX) SIGCONT18Continue executing, if stopped (POSIX) SIGSTOP19Stop executing(can't be caught or ignored) (POSIX) SIGTSTP20Terminal stop signal (POSIX) Ctrl-Z or Ctrl-F SIGTTIN21Background process trying to read, from TTY (POSIX) SIGTTOU22Background process trying to write, to TTY (POSIX) SIGURG23Urgent condition on socket (4.2 BSD) SIGXCPU24CPU limit exceeded (4.2 BSD) SIGXFSZ25File size limit exceeded (4.2 BSD) SIGVTALRM26Virtual alarm clock (4.2 BSD) SIGPROF27Profiling alarm clock (4.2 BSD) SIGWINCH28Window size change (4.3 BSD, Sun) SIGIO29I/O now possible (4.2 BSD) SIGPWR30Power failure restart (System V)

CIS 90 - Lesson 10 /home/cis90/roddyduk $ kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR 31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3 38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8 43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2 63) SIGRTMAX-1 64) SIGRTMAX /home/cis90/roddyduk $ Signals Use kill –l to see all of them

CIS 90 - Lesson 10 Signals Special keystrokes /home/cis90/roddyduk $ stty -a speed baud; rows 26; columns 78; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ; eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^F; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; ~]$ stty -a speed baud; rows 39; columns 84; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ; eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; use stty –a to see special keystrokes

CIS 90 - Lesson 10 Signals Jim's app script

CIS 90 - Lesson 10 Signals Benji runs app Benji logs in and runs app … uh oh, its stuck !

CIS 90 - Lesson 10 Signals Benji runs app Benji tries using the keyboard to send a SIGINT using Ctrl-C but nothing happens (because app is ignoring SIGINT)

CIS 90 - Lesson 10 Signals Benji runs app Benji tries using the keyboard to send a SIGQUIT using Ctrl-\ but but app reacts by saying "quit it"

CIS 90 - Lesson 10 Signals Benji runs app Benji asks his friend Duke to kill off his stalled app process. Duke uses ps to look it up but does not have permission to kill it off

CIS 90 - Lesson 10 Signals Benji runs app Benji logs into another Putty session and sends a SIGINT using the kill command …. but nothing happens

CIS 90 - Lesson 10 Signals Benji runs app Benji ups the anty and sends two SIGQUITs (-3) but the app process shrugs them off with "quit it!" messages

CIS 90 - Lesson 10 Signals Benji runs app Benji decides to send a SIGTERM (-15) this time and the app process finishes, cleans up and exits

CIS 90 - Lesson 10 Signals Benji runs app The same thing happens again another day. This time Benji does not care what happens with app …

CIS 90 - Lesson 10 Signals Benji runs app So he sends a SIGKILL this time … and app never even sees it coming …. poof … app is gone

CIS 90 - Lesson 10 Signals Class Exercise View the../depot/app program Look for the three trap handlers Signal 2 (SIGINT) Signal 3 (SIGQUIT) Signal 15 (SIGTERM) Run app Try sending it a SIGINT from the keyboard (Ctrol-C) Try sending it a SIGQUIT from the keyboard (Ctrl-\) Login to another Putty session Use the ps –u $LOGNAME to find the app PID Send it a SIGINT (kill -2 PID) Send it a SIGQUIT (kill -3 PID) Now send either a SIGKILL (9) or SIGTERM (15) but first decide if app can clean up or not when it gets your signal.

CIS 90 - Lesson 10 Load Balancing

CIS 90 - Lesson 10 Load Balancing So that the multiprocessing CPU on a UNIX system does not get overloaded, some processes need to be run during low peak hours such as early in the morning or later in the day. The at command is for this purpose. The at command reads its stdin for a list of commands to run, and begins running them at the time of day specified as the first argument: $ at 10:30pm < batch_file $ at 11:59pm at> cat files.out bigshell > lab08 at> cp lab08 /home/rsimms/cis90/$LOGNAME at> Ctrl-D $ Note: the Ctrl-d must be entered as the first character on the last line.

CIS 90 - Lesson 10 Load Balancing Several ways to specify a future time to run This job makes a backup of myscript and sends an when finished Use the atq command to show queued jobs

CIS 90 - Lesson 10 Load Balancing The atrm command is used to remove jobs from the queue The jobs command lists processes running or suspended in the background. The atq command lists jobs queued to run in the futures that were scheduled by at command

CIS 90 - Lesson 10 The Test

CIS 90 - Lesson 10 Wrap up

CIS Lesson 8 New commands: Ctrl-Z or FSuspends a foreground process bgResumes suspended process &Runs command in the background fgBrings background job to foreground jobsshow background jobs killSend a signal to a process atRun job once in the future atqShow all at jobs queued to run atrmRemove at jobs from queue

CIS 90 - Lesson 10 Next Class Assignment: Check Calendar Page on web site to see what is due next week. Quiz questions for next class: What command shows the current running processes? Name four states a process can be in. What is the difference between the fork and exec system calls?

CIS 90 - Lesson 10 Backup