Annotation of researchv10dc/man/adm/man2/signal.2, revision 1.1.1.1

1.1       root        1: .TH SIGNAL 2
                      2: .CT 2 proc_man
                      3: .SH NAME
                      4: signal, kill \(mi receive and send signals
                      5: .SH SYNOPSIS
                      6: .nf
                      7: .B #include <signal.h>
                      8: .PP
                      9: .B SIG_TYP (*signal(sig, func))()
                     10: .B SIG_TYP (*func)();
                     11: .PP
                     12: .B int kill(pid, sig)
                     13: .fi
                     14: .SH DESCRIPTION
                     15: A signal
                     16: is generated by some abnormal event
                     17: initiated by a user at a terminal (quit, interrupt),
                     18: by a program error (bus error, etc.),
                     19: or by
                     20: .I kill
                     21: in another process.
                     22: Normally, most signals
                     23: cause termination of the receiving process,
                     24: but
                     25: .I signal
                     26: allows them either to be ignored
                     27: or to be caught by interrupting to a specified function.
                     28: The following signal names are defined in
                     29: .FR <signal.h> :
                     30: .LP
                     31: .nf
                     32: .ta \w'SIGMMMM 'u +\w'15*  'u
                     33: \fLSIGHUP\fP   1       hangup
                     34: \fLSIGINT\fP   2       interrupt
                     35: \fLSIGQUIT\fP  3*      quit
                     36: \fLSIGILL\fP   4*      illegal instruction (not reset when caught)
                     37: \fLSIGTRAP\fP  5*      trace trap (not reset when caught)
                     38: \fLSIGIOT\fP   6*      IOT instruction
                     39: \fLSIGEMT\fP   7*      EMT instruction
                     40: \fLSIGFPE\fP   8*      floating point exception
                     41: \fLSIGKILL\fP  9       kill (cannot be caught or ignored)
                     42: \fLSIGBUS\fP   10*     bus error
                     43: \fLSIGSEGV\fP  11*     segmentation violation
                     44: \fLSIGSYS\fP   12*     bad argument to system call
                     45: \fLSIGPIPE\fP  13      write on a pipe with no one to read it
                     46: \fLSIGALRM\fP  14      alarm clock
                     47: \fLSIGTERM\fP  15      software termination signal
                     48:        16      unassigned
                     49: \fLSIGSTOP\fP  17+     stop (cannot be caught or ignored)
                     50: \fLSIGCONT\fP  19#     continue a stopped process
                     51: \fLSIGCHLD\fP  20#     child has stopped or exited
                     52: .sp
                     53: .fi
                     54: *      places core image in file
                     55: .B core
                     56: if not caught or ignored
                     57: .br
                     58: +      suspends process until
                     59: .B SIGCONT
                     60: or
                     61: .BR PIOCRUN ;
                     62: see
                     63: .IR proc (4)
                     64: .br
                     65: #      ignored if not caught
                     66: .PP
                     67: Signals 1 through
                     68: .BR NSIG -1,
                     69: defined in the include file, exist.
                     70: Those not listed above have
                     71: no conventional meaning in this system.
                     72: (Berkeley systems use 1-15 and 17-25.)
                     73: .PP
                     74: .I Signal
                     75: specifies how signal
                     76: .I sig
                     77: will be handled.
                     78: If
                     79: .I func
                     80: is
                     81: .BR SIG_DFL ,
                     82: the default action listed above is reinstated.
                     83: If
                     84: .I func
                     85: is
                     86: .BR SIG_IGN ,
                     87: the signal will be ignored.
                     88: Otherwise the signal will be caught; when the signal occurs,
                     89: the function pointed to by
                     90: .IR func ,
                     91: say
                     92: .IR catcher (),
                     93: defined thus,
                     94: .EX
                     95: .L
                     96:         int catcher(sig) { ... }
                     97: .EE
                     98: will be called with the
                     99: signal number as argument.
                    100: A return from the function will
                    101: continue the process at the point it was interrupted.
                    102: .PP
                    103: Except as indicated, a signal is reset to
                    104: .B SIG_DFL
                    105: after being caught.
                    106: Thus if it is desired to catch every such signal,
                    107: the catching routine must issue another
                    108: .I signal
                    109: call.
                    110: .PP
                    111: When a caught signal occurs
                    112: during certain system calls, the call terminates prematurely.
                    113: In particular this can occur during
                    114: .IR read (2)
                    115: or
                    116: .IR write
                    117: on a slow device (like a typewriter, but not a disk),
                    118: and during
                    119: .IR pause 
                    120: and
                    121: .IR wait ;
                    122: see
                    123: .IR alarm (2)
                    124: and
                    125: .IR exit (2).
                    126: The interrupted system call will return error
                    127: .BR EINTR .
                    128: The user's program may then, if it wishes, re-execute the call.
                    129: .PP
                    130: .I Signal
                    131: returns the previous (or initial)
                    132: value of
                    133: .I func
                    134: for the particular signal.
                    135: .PP
                    136: After a
                    137: .IR  fork (2)
                    138: the child inherits all signal settings.
                    139: .IR  Exec (2)
                    140: resets all caught signals to default action.
                    141: .PP
                    142: .I Kill
                    143: sends signal
                    144: .I sig
                    145: to the process specified by process id
                    146: .I pid.
                    147: Signal 0
                    148: has no effect on the target process and may be used to
                    149: test the existence of a process.
                    150: The success of sending a signal is independent of how the receiving
                    151: process treats the signal.
                    152: .PP
                    153: The effective userid of the sending process must be either 0
                    154: or the effective userid of the receiving process.
                    155: .PP
                    156: If
                    157: .I pid
                    158: is 0, the signal is sent to all other processes in the
                    159: sender's process group; see
                    160: .IR stream (4).
                    161: .PP
                    162: If
                    163: .I pid
                    164: is \-1, and the user is the super-user,
                    165: the signal is broadcast universally
                    166: except to processes 0 (scheduler),
                    167: 1 (initialization)
                    168: and 2 (pageout); see
                    169: .IR init (8).
                    170: If
                    171: .I pid
                    172: is less than \-1,
                    173: it is negated
                    174: and taken as a process group
                    175: whose members should receive the signal.
                    176: .PP
                    177: Processes may send signals to themselves.
                    178: .SH FILES
                    179: .F core
                    180: .SH "SEE ALSO"
                    181: .IR kill (1),
                    182: .IR setjmp (3),
                    183: .IR stream (4)
                    184: .SH DIAGNOSTICS
                    185: .IR signal :
                    186: .B EINVAL
                    187: .br
                    188: .IR kill :
                    189: .BR EINVAL ,
                    190: .BR EPERM ,
                    191: .BR ESRCH
                    192: .SH BUGS
                    193: The reason for a trap should be distinguishable by extra arguments
                    194: to the signal handler.
                    195: .br
                    196: If a repeated signal arrives before the last one can be reset,
                    197: there is no chance to catch it.
                    198: .br
                    199: For historical reasons, the return value of
                    200: a catcher function is
                    201: .BR int ;
                    202: it is 
                    203: .B void
                    204: in 
                    205: .SM ANSI
                    206: standard C.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.