home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 38.8 What Are Signals? Chapter 38
Starting, Stopping, and Killing Processes
Next: 38.10 Destroying Processes with kill
 

38.9 Killing Foreground Jobs

You probably know that typing CTRL-c ( 38.8 ) will terminate your foreground job. But what actually happens when you type CTRL-c?

When you type CTRL-c, you're sending the INT (interrupt) signal ( 38.8 ) to the foreground process. Most well-designed programs "catch" the interrupt signal - which means that the program installs some special function (a "signal handler") that is called whenever a signal arrives. The signal handler normally closes all open files, resets your terminal properly (if needed), and does anything else necessary so that the program can depart from this world at peace. Then the program terminates. The QUIT signal, sent by CTRL- \ , works similarly but also makes a core file ( 52.9 ) for debugging.

Of course, it's possible for the signal handler to do something else entirely: it's possible for the program to decide not to quit, or to implement some truly bizarre feature. In fact, editors like vi or Emacs almost always ignore most signals. The trap ( 44.12 ) command handles signals in the Bourne shell.

Whenever you send a signal from the keyboard, it's sent to all processes in the same process group ( 38.3 ) . This may include the program's child processes, but may not. And, of course, child processes can choose to ignore signals on their own. But more often than not, killing the parent process kills its children.

Article 5.9 explains how to set the key that sends these and other signals. The kill ( 38.10 ) command also sends signals.

- ML , JP


Previous: 38.8 What Are Signals? UNIX Power Tools Next: 38.10 Destroying Processes with kill
38.8 What Are Signals? Book Index 38.10 Destroying Processes with kill

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System