ugh.book

(singke) #1
The Unix Attitude 39

have the same name, namely “latex,” because they are all LaTeX
jobs. Thus, “kill -9 latex” would be ambiguous.


Like most operating systems, Unix has a command to list your jobs,
mnemonically named “jobs.” The output of jobs looks something
like this:


zvona@rice-chex> jobs
[1] - Stopped latex
[2] - Stopped latex
[3] + Stopped latex

This readily lets you associate particular LaTeX jobs with job num-
bers, displayed in the square brackets.


If you have had your thinking influenced by less well-thought-out
operating systems, you may be thinking at this point that “kill -9 1”
would kill job 1 in your listing. You’ll find, however, that it actually
gives you a friendly error message:


zvona@rice-chex> kill -9 1
1: not owner

The right argument to kill is a process id. Process ids are numbers
like 18517. You can find the process id of your job using the “ps”
command, which lists jobs and their process ids. Having found the
right process id, you just:


zvona@rice-chex> kill -9 18517
zvona@rice-chex>
[1] Killed latex

Notice that Unix gives you the prompt before telling you that your
job has been killed. (User input will appear after the line beginning
with “[1]”.) This illustrates another Unix design principle:


  • Tell the user no more than he needs to know, and no earlier than he
    needs to know it. Do not burden his cognitive capacities with excess
    information.


I hope this little exercise has been instructive for you. I certainly
came away from my learning experience deeply impressed with the
Unix design philosophy. The elegance, power, and simplicity of the
Unix kill command should serve as a lesson to us all.

Free download pdf