CPS 346 & 444/544 Lecture notes: Signals
Coverage:
[UPE] Chapters 1 (pp. 33-35), 3 (p. 73), 5 (pp. 150-152),
and [USP] Chapters 3 (pp. 84-85), 8 (pp. 255-260),
and 11 (pp. 398-401)
Shell job control
- a shell has job control if it provides support for
moving processes from the foreground to the background and
vice versa
- concurrent execution
jobs: command which lists the current jobs
[1] + Stopped spell termpaper
[2] - Running find /usr -name main.exe -print &
|
- + denotes current job;
default for fg and bg
- - denotes previous job
management
- $ <ctrl-c>: kills current foreground process
- $ fg %<number>: moves a running or stopped
background job to the foreground
- $ <ctrl-z>: suspends the current job and moves
it to the background in the stopped state in one stroke
- $ bg %<number>:
resumes execution of a stopped job in the background.
- combo of <ctrl-z> bg makes a
foreground job a running background job
- $ ps: lists the running processes
PID TT STAT TIME COMMAND
12360 p0 S 0:01 -ksh (ksh)
12372 p0 I 0:00 main
12425 p0 R 0:00 ps -x
|
- ps -u cps346-01.15
- ps -e # standard syntax
- ps aux # BSD syntax
- $ kill -l: list all signals
- $ kill -STOP %<number>: suspends a running background job
- $ kill %<number>: terminates the process with
the corresponding job number
- $ kill [-signum] <PID>:
terminates the process with the corresponding process id;
can pass kill a signal #
- -15 (default)
- -2 (intr; same as <ctrl-c>)
- -9 (sure kill; process cannot inoculate itself against this
signal)
- -3 (quit; same as <ctrl-\>)
originally no job control in Bourne shell
graphical depiction:
X-Windows
- ssh -X ...
- xterm
- rxvt -ls
- window managers
- motif (lesstif)
- open windows
- next step
- cut and paste through clicking the middle mouse button
X server
take away:
- a server is both hardware and software; in order words,
there must be a process to respond to a request (i.e., the
software is a necessary component)
- a computer can function as both a client and sever at the same time,
in different contexts, of course
- the two primary interprocess communication methods are I/O (e.g.,
pipes, sockets), if the processes share a common ancestor, and signals,
if they do not share a common ancestor
More job control
References
| [UPE] |
B.W. Kernighan and R. Pike. The UNIX Programming Environment.
Prentice Hall, Upper Saddle River, NJ, Second edition, 1984.
|
| [USP] |
K.A. Robbins and S. Robbins.
UNIX Systems Programming: Concurrency, Communication, and Threads.
Prentice Hall, Upper Saddle River, NJ, Second edition, 2003. |
|