From Wikipedia, the free encyclopedia
SIGCHLD
Description |
Child process terminated or stopped |
Default action |
Ignore the signal |
|
SA_SIGINFO macros
|
CLD_EXITED |
child has exited |
CLD_KILLED |
child has terminated abnormally and did not create a core file |
CLD_DUMPED |
child has terminated abnormally and created a core file |
CLD_TRAPPED |
traced child has trapped |
CLD_STOPPED |
child has stopped |
CLD_CONTINUED |
stopped child has continued |
|
On POSIX-compliant platforms, SIGCHLD is the signal sent by computer programs when a child process terminates. The symbolic constant for SIGCHLD is defined in the header file signal.h
. Symbolic signal names are used because signal numbers can vary across platforms.
On Linux, SIGCLD is a synonym for SIGCHLD.
[edit] Etymology
SIG is a common prefix for signal names. CHLD and CLD are abbreviations for child.
In Unix, a process can have children, created by fork or similar system calls. When the child terminates a SIGCHLD signal is sent to the parent. By default the signal is ignored and a zombie process is created[1]. The parent must install a handler to act on the signal. Zombies can be avoided on most Unix platforms by explicitly ignoring SIGCHLD[2][3]. This is shown in various languages in the table below. However, installing a signal handler for SIGCHLD and calling wait remain the most portable way to avoid zombies.
Language |
Syntax |
C |
signal(SIGCHLD, SIG_IGN); |
Perl |
$SIG{CHLD} = 'IGNORE'; |
Python |
signal.signal(signal.SIGCHLD, signal.SIG_IGN) |
PHP |
pcntl_signal(SIGCHLD, SIG_IGN); |
[edit] References
- ^ Advanced Programming in the UNIX Environment - W. Stevens
- ^ perlipc - perldoc.perl.org
- ^
sigaction(3)
: examine and change a signal action – Linux man page