A Walk Through Some of the Most Popular Linux Signals
My last two columns talked about the Linux (and POSIX) signal API and how to use it to write programs that handle signals. Now that you understand what signals are and how they can be manipulated by your application, I want to talk about some of the most commonly used signals. For each signal, I’ll describe when the signal is sent, what the default action is, and how most programs handle it. Remember that the type of action a particular signal should invoke is mostly a convention. Users will expect a certain behavior, but programs can do pretty much whatever they like.
My last two columns talked about the Linux (and POSIX) signal API and how to use it to write programs that handle signals. Now that you understand what signals are and how they can be manipulated by your application, I want to talk about some of the most commonly used signals. For each signal, I’ll describe when the signal is sent, what the default action is, and how most programs handle it. Remember that the type of action a particular signal should invoke is mostly a convention. Users will expect a certain behavior, but programs can do pretty much whatever they like.
Terminating Processes
SIGABRT: The abort signal is normally sent by a program when it wants to terminate itself and leave a core dump around. This can be handy during debugging and when you want to check assertions in code. The easiest way for a process to send a SIGABRT to itself is via the (ANSI-C) abort() function, which does nothing more than a (also ANSI-C) raise(SIGABRT), which, in turn, does a (not ANSI-C) kill(getpid(), SIGABRT). Programs normally drop a core file and exit when receiving this signal.
C’s built-in assertion facility, cleverly named assert(), calls abort() when an assertion fails, as do many memory-debugging libraries. Doing this rather then a simple exit() gives the developer a core file to work with and also allows debuggers to catch the signal and let the developer poke around.
SIGQUIT: Like SIGABRT, SIGQUIT normally causes a program…
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: