A signal is a message that can be sent to a running process.
Programs, users, or administrators can initiate signals.
For example, the proper method of telling the Internet Daemon (inetd) to re-read its configuration file is to send it a SIGHUP signal.
For example, if the current process ID (PID) of inetd is 4140, type:
kill -SIGHUP 4140
Another common use of signals is to stop a running process. To stop the inetd process completely, use this command:
kill 4140
By default, the kill command sends the SIGTERM signal. If SIGTERM fails, escalate to using the SIGKILL signal to stop the process:
kill -9 4140
Because SIGKILL cannot be handled, stopping a process with SIGKILL is generally considered a bad idea. Using SIGKILL prevents a process from cleaning up after itself and exiting gracefully.
Handling Signals
Each Unix signal has a default set of effects on a Unix program. Programmers can code their applications to respond in customized ways to most signals. These custom code pieces are called signal handlers.
A signal handler is unable to redefine two signals. SIGKILL always stops a process and SIGSTOP always moves a process from the foreground to the background. A signal handler cannot “catch” these two signals.
FreeBSD Signals
Signal Name | Signal Number | Signal Description |
---|---|---|
SIGHUP | 1 | Terminal line hangup |
SIGINT | 2 | Interrupt program |
SIGQUIT | 3 | Quit program |
SIGILL | 4 | Illegal instruction |
SIGTRAP | 5 | Trace trap |
SIGABRT | 6 | Abort |
SIGEMT | 7 | Emulate instruction executed |
SIGFPE | 8 | Floating-point exception |
SIGKILL | 9 | Kill program |
SIGBUS | 10 | Bus error |
SIGSEGV | 11 | Segmentation violation |
SIGSYS | 12 | Bad argument to system call |
SIGPIPE | 13 | Write on a pipe with no one to read it |
SIGALRM | 14 | Real-time timer expired |
SIGTERM | 15 | Software termination signal |
SIGURG | 16 | Urgent condition on I/O channel |
SIGSTOP | 17 | Stop signal not from terminal |
SIGTSTP | 18 | Stop signal from terminal |
SIGCONT | 19 | A stopped process is being continued |
SIGCHLD | 20 | Notification to parent on child stop or exit |
SIGTTIN | 21 | Read on terminal by background process |
SIGTTOU | 22 | Write to terminal by background process |
SIGIO | 23 | I/O possible on a descriptor |
SIGXCPU | 24 | CPU time limit exceeded |
SIGXFSZ | 25 | File-size limit exceeded |
SIGVTALRM | 26 | Virtual timer expired |
SIGPROF | 27 | Profiling timer expired |
SIGWINCH | 28 | Window size changed |
SIGINFO | 29 | Information request |
SIGUSR1 | 30 | User-defined signal 1 |
SIGUSR2 | 31 | User-defined signal 2 |
SIGTHR | 32 | Thread interrupt |
Solaris Signals
Signal Name | Signal Number | Signal Description |
---|---|---|
SIGHUP | 1 | Hangs up |
SIGINT | 2 | Interrupts |
SIGQUIT | 3 | Quits |
SIGILL | 4 | Illegal instruction |
SIGTRAP | 5 | Trace trap |
SIGABRT | 6 | Used by abort |
SIGEMT | 7 | EMT instruction |
SIGFPE | 8 | Floating-point exception |
SIGKILL | 9 | Kill (cannot be caught or ignored) |
SIGBUS | 10 | Bus error |
SIGSEGV | 11 | Segmentation violation |
SIGSYS | 12 | Bad argument to system call |
SIGPIPE | 13 | Writes on a pipe with no one to read it |
SIGALRM | 14 | Alarm clock |
SIGTERM | 15 | Software termination |
SIGUSR1 | 16 | User-defined signal 1 |
SIGUSR2 | 17 | User-defined signal 2 |
SIGCHLD | 18 | Child status change alias (POSIX) |
SIGPWR | 19 | Power-fail restart |
SIGWINCH | 20 | Window size change |
SIGURG | 21 | Urgent socket condition |
SIGPOLL /SIGIO | 22 | Pollable event occurred or Socket I/O possible |
SIGSTOP | 23 | Stop (cannot be caught or ignored) |
SIGTSTP | 24 | User stop requested from TTY |
SIGCONT | 25 | Stopped process has been continued |
SIGTTIN | 26 | Background TTY read attempted |
SIGTTOU | 27 | Background TTY write attempted |
SIGVTALRM | 28 | Virtual timer expired |
SIGPROF | 29 | Profiling timer expired |
SIGXCPU | 30 | Exceeded CPU limit |
SIGXFSZ | 31 | Exceeded file size limit |
SIGWAITING | 32 | Process’ LWPs are blocked |
SIGLWP | 33 | Special signal used by thread library |
SIGFREEZE | 34 | Special signal used by CPR |
SIGTHAW | 35 | Special signal used by CPR |
SIGCANCEL | 36 | Thread cancellation signal used by libthread |
SIGLOST | 37 | Resource lost |
SIGRTMIN | 38 | Highest priority real-time signal |
SIGRTMAX | 45 | Lowest priority real-time signal |
eric
this was very helpful. finally, information when you ask for it with a simple search