CT320

CT320: Network and System Administration

Fall 2017

Processes

See this page as a slide show

CT 320: Network and System Administration

CHAPTER 5: CONTROLLING PROCESSES

Original slides from Dr. James Walden at Northern Kentucky University.

Topics

  1. Components
  2. Life cycle of a process
  3. Signals
  4. Process states
  5. /proc
  6. Monitoring processes

Components of a Process

Address space

Kernel’s internal data structures

Process Identification Numbers

User Identification Numbers

Group IDentification numbers

Priority

Nice Value

Archbishop Desmond Tutu

Control Terminal

Topics

  1. Components
  2. Life cycle of a process
  3. Signals
  4. Process states
  5. /proc
  6. Monitoring processes

Life cycle of a Process

fork()

exec()

clone()

systemd or upstart or init

wait()

Topics

  1. Components
  2. Life cycle of a process
  3. Signals
  4. Process states
  5. /proc
  6. Monitoring processes

Signals

Actions on Receipt of a Signal

Blocking or Ignoring Signals

List of signals

$ 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	

Common Signals

#NameDescDefaultCatch?Block?Core?
1SIGHUPHangupTermYYN
2SIGINTInterruptTermYYN
3SIGQUITQuitTermYYY
9SIGKILLKillTermNNN
 SIGBUSBus ErrorTermYYY
15SIGTERMTerminateTermYYN
 SIGCHLDChild deathIgnoreYYN
 SIGUSR1User-def1TermYYN
 SIGUSR2User-def2TermYYN
 SIGSTOPStopStopNNN

What are signals used for?

Sliding scale of manual process termination:

What are Signals Used For?

What are signals used for?

What are signals used for?

What are signals used for?

Sending Signals

List of signals

$ 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	

killall

Topics

  1. Components
  2. Life cycle of a process
  3. Signals
  4. Process states
  5. /proc
  6. Monitoring processes

Process States

StateMeaning
RunnableThe process can be executed
SleepingThe process is waiting for resources
ZombieThe process is waiting to die
StoppedThe process is suspended

Process States

Process States

Topics

  1. Components
  2. Life cycle of a process
  3. Signals
  4. Process states
  5. /proc
  6. Monitoring processes

/proc

/proc

Process info files in /proc

FileContents
/proc/pid/cmdCommand or program the process is executing
/proc/pid/cmdlineComplete command line of the process
/proc/pid/cwdSymbolic link to the process’s current directory
/proc/pid/environThe process’s environment variables
/proc/pid/exeSymbolic link to the file being executed
/proc/pid/fdSubdirectory with links for each open descriptor
/proc/pid/mapsMemory mapping info
/proc/pid/rootSymbolic link to the process’s root directory
/proc/pid/statGeneral process status information
/proc/pid/statmMemory usage information

Topics

  1. Components
  2. Life cycle of a process
  3. Signals
  4. Process states
  5. /proc
  6. Monitoring processes

ps & top

ps:

top:

strace

Runaway processes

Signal code

A sample program that deals with signals:

$ cat ~applin/bin/signals
#! /usr/bin/env run-c

#include <stdio.h>			// for printf()
#include <signal.h>			// for signal()
#include <unistd.h>			// for sleep()

void handler() {			// I get called for SIGINT.
    printf("Ouch!\n");
    signal(SIGINT, handler);		// Re-install signal handler
}

int main() {
    signal(SIGINT, handler);		// Call handler() upon interrupt.
    for (int i=1; i<=300; i++) {	// five minutes
	printf("%d\n", i);
	sleep(1);			// Kill some time.
    }
}

Modified: 2017-11-16T16:06

User: Guest

Check: HTML CSS
Edit History Source
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2015 Colorado State University
CS Building