|
In 1957, Ken Olsen and a group of his buddies got tired of the sales practices
of IBM corporation and started their own computer company, Digital Equipment
Corporation. They started building much cheaper mainframes which became
really popular. Unix was originally designed on a Digital Equipment machine.
|
ps, kill - process management programs
Unix is a multitasking operating system, which means it can run multiple
processes at once. A process is a running program.
The first process you'll see when you log in is the
shell. The shell allows you to start other processes.
Most shells allow you to start a process in the background using the '&'
operator.
[18]Tethys% rm -fr * &
[1] 90463
[19]Tethys%
This deletes all the files in the current directory in the background. Being
in the background as it is, you can interact with the shell as the background
job does it's thing. The [1] tells you the job number so you can pull the
job back into the foreground if neccesary. The 90463 tells you the Process
ID, which is the system-wide unique number that identifies your process.
You can see all the processes, complete with their IDs by running the
ps command.
[19]Tethys% ps
PID TT STAT TIME COMMAND
90280 p1 Ss 0:00.08 -csh (csh)
90463 p1 T 0:00.20 rm -fr *
90470 p1 R+ 0:00.00 ps
Here we see our shell (csh), our background file deletion (rm), and the
process listing our processes which we just ran (ps).
Processes under Unix can intercommunicate by sending signals - special
messages that command a process to perform a certain action.
There are several signals that can be sent to a process. A program can
decide how to react when it receives a certain signal, however usually
a given signal will produce the same sort of result in any program.
You can send signals to processes yourself using the kill program.
[20]Tethys% ps
PID TT STAT TIME COMMAND
90280 p1 Ss 0:00.08 -csh (csh)
90463 p1 T 0:00.20 rm -fr *
90470 p1 R+ 0:00.00 ps
[21]Tethys% kill -KILL 90463
[22]Tethys%
The -KILL part of the previous command tells the kill program that the signal
you want to send it is the KILL signal.
Here are some of the signals that processes usually can receive:
- HUP - The HUP signal's original purpose was to tell a program
that it's controlling terminal had hung up (ie - a dialup shell connection had
dropped). It's now also used to tell system daemon (background) processes
(which don't have a controlling terminal) to restart and reread their
configuration files.
- INT - the INT signal tells a process that the user has hit the interrupt
key sequence (usually CTRL+C, but can be reconfigured using the `stty' program).
Usually programs exit upon receiving this signal.
- KILL - This is the signal after which the `kill' program was named, as it's
usually used to send the KILL signal. KILL is one of two signals a process
doesn't get to choose how to react to - KILL makes a process exit.
- QUIT - Another signal you can send to a process using a keyboard
combination - CTRL+\ (depending on whether you've reconfigured it with the
`stty' program). Programs almost always exit in response to a QUIT signal,
even if they don't respond to an INT signal.
- TERM - This is the default signal the `kill' program sends:
[22]Tethys% kill 216
This command sends a TERM signal to process 216. Programs that
need to "shutdown" properly before exiting hope to receive this signal
before a KILL signal, because they can't respond to a KILL signal.