Five conditions generate signals:

1. The kill system call allows a process to send a signal to another process or to itself. A signal, however, does not always terminate a process; some inform the process of a condition that the receiving process handles. To send a signal, the sending and receiving process must have the same user ID, or the sending process must be root.

2. The kill command is a program that takes its command line arguments and issues a kill system call.

3. Certain terminal characters generate signals. E.g., every interactive terminal is associated with an interrupt character and a quit character. The interrupt char.(usu. Ctrl-C or Delete) terminates a running process, and generates a SIGINT signal. The quit char. (usu. Ctrl-backslash) terminate a running process and generates a core image of it. This generates a SIGQUIT signal. You can set the interrupt character and quit character to almost any term character that you want. 4.3BSD has a terminal suspend character (usu. Ctrl-Z) to immediately generate a SIGTSTP signal, as well as a delayed terminal suspend character (usu. Ctrl-Y). The latter generates a SIGTSTP signal when the process attempts to read the character. The aforementioned signals are sent to the running process and to all processes in the terminal control group. They are normally sent from the kernel to a process.

4. Certain hardware conditions. E.g. floating point arithmetic errors generate a SIGFPE error. Referencing an address outside of a process' address space generates a SIGSEGV signal. The conditions and their generated signals can differ from one Unix implementation to another. These signals are normally sent from the kernel to a process.

5. Certain software conditions. E.g., the SIGURG signal is generated when out-of-band data arrives on a socket.

What a process can do with a signal:

1. Provide a function called a signal handler, which is called whenever a specific type of signal occurs (and remains installed after a signal occurs). It can do whatever the process wants to handle the condition - called catching the signal. BSD allows a process to block and unblock receipt of signals with a new system call, so when a process receives a signal, the kernel automatically blocks further receipt of the signal until the signal handler completes.

2. Ignore it. All signals, with the exception of SIGKILL and SIGSTOP, can be ignored.

3. Allow the default to occur. Normally a process is terminated on receipt of a signal, and certain signals generate a core image of the process in its current working directory. Under 4.3BSD, however, the default action for the SIGURG, SIGTSTP, SIGTTIN, and SIGTTOU signals is to stop the process.

The signal is remembered for delivery. This is called blocking a signal under 4.3BSD and holding a signal under System V. Both implementations can release one or more signals that are blocked while waiting for a signal to occur. The kernel handles signals only when a process returns from kernel mode to user mode. A process must run to handle signals. According to Dennis Ritchie, signals were designed as events that are fatal or ignored, and not necesarily handled.

Log in or register to write something here or to contact authors.