SIGPIPE
From Wikipedia, the free encyclopedia
Description: | Write on a pipe with no one to read it |
---|---|
Default action: | Abnormal termination of the process |
SA_SIGINFO macros | |
None |
On POSIX-compliant platforms, SIGPIPE is the signal thrown when a computer program attempts to write to a pipe without a process connected to the other end. The symbolic constant for SIGPIPE is defined in the header file signal.h
. Symbolic signal names are used because signal numbers can vary across platforms.
[edit] Etymology
SIG is a common prefix for signal names. PIPE refers to the Unix pipe.
[edit] Description
Unix supports the principle of piping, which allows processes to send data to other processes without the need for creating temporarily files. When a pipe is broken, the process writing to it is sent the SIGPIPE signal. The default reaction to this signal for a process is to terminate.
A simple example of piping is the following.
ps l | grep make
This command, when run on a Unix-like machine (including Linux), returns a list of all processes with 'make' in their name.
- ps l returns a list of all processes (including those of other users).
- grep make selects all lines that contain the word 'make'.
If, for whatever reason, grep cannot start, the pipe is considered to be broken. SIGPIPE is sent to ps, which will terminate: It is no use writing data that no one will use.
POSIX Signals |
SIGABRT | SIGALRM | SIGFPE | SIGHUP | SIGILL | SIGINT | SIGKILL | SIGPIPE | SIGQUIT | SIGSEGV | SIGTERM | SIGUSR1 | SIGUSR2 | SIGCHLD | SIGCONT | SIGSTOP | SIGTSTP | SIGTTIN | SIGTTOU | SIGBUS | SIGPOLL | SIGPROF | SIGSYS | SIGTRAP | SIGURG | SIGVTALRM | SIGXCPU | SIGXFSZ | Realtime Signals are user definable—SIGRTMIN+n through SIGRTMAX. |
Common non-POSIX signals and synonyms |
SIGIOT | SIGEMT | SIGSTKFLT | SIGIO | SIGCLD | SIGINFO | SIGPWR (SIGINFO) | SIGLOST | SIGWINCH | SIGUNUSED |