|
|
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, when the signal occurs, it will be caught and ! 89: a function, pointed to by ! 90: .IR func , ! 91: will be called. ! 92: The type of pointer ! 93: .I func ! 94: is ! 95: .BR SIG_TYP : ! 96: .IP ! 97: .B typedef int (*SIG_TYP)(); ! 98: .LP ! 99: It must point to a function such as, ! 100: .EX ! 101: .L ! 102: int catcher(sig) { ... } ! 103: .EE ! 104: which will be called with a ! 105: signal number as argument. ! 106: A return from the catcher function will ! 107: continue the process at the point it was interrupted. ! 108: .PP ! 109: Except as indicated, a signal is reset to ! 110: .B SIG_DFL ! 111: after being caught. ! 112: Thus if it is desired to catch every such signal, ! 113: the catching routine must issue another ! 114: .I signal ! 115: call. ! 116: .PP ! 117: When a caught signal occurs ! 118: during certain system calls, the call terminates prematurely. ! 119: In particular this can occur during ! 120: .IR read (2) ! 121: or ! 122: .IR write ! 123: on a slow device (like a typewriter, but not a disk), ! 124: and during ! 125: .IR pause ! 126: and ! 127: .IR wait ; ! 128: see ! 129: .IR alarm (2) ! 130: and ! 131: .IR exit (2). ! 132: The interrupted system call will return error ! 133: .BR EINTR . ! 134: The user's program may then, if it wishes, re-execute the call. ! 135: .PP ! 136: .I Signal ! 137: returns the previous (or initial) ! 138: value of ! 139: .I func ! 140: for the particular signal. ! 141: .PP ! 142: After a ! 143: .IR fork (2) ! 144: the child inherits all signal settings. ! 145: .IR Exec (2) ! 146: resets all caught signals to default action. ! 147: .PP ! 148: .I Kill ! 149: sends signal ! 150: .I sig ! 151: to the process specified by process id ! 152: .I pid. ! 153: Signal 0 ! 154: has no effect on the target process and may be used to ! 155: test the existence of a process. ! 156: The success of sending a signal is independent of how the receiving ! 157: process treats the signal. ! 158: .PP ! 159: The effective userid of the sending process must be either 0 ! 160: or the effective userid of the receiving process. ! 161: .PP ! 162: If ! 163: .I pid ! 164: is 0, the signal is sent to all other processes in the ! 165: sender's process group; see ! 166: .IR stream (4). ! 167: .PP ! 168: If ! 169: .I pid ! 170: is \-1, and the user is the super-user, ! 171: the signal is broadcast universally ! 172: except to processes 0 (scheduler), ! 173: 1 (initialization) ! 174: and 2 (pageout); see ! 175: .IR init (8). ! 176: If ! 177: .I pid ! 178: is less than \-1, ! 179: it is negated ! 180: and taken as a process group ! 181: whose members should receive the signal. ! 182: .PP ! 183: Processes may send signals to themselves. ! 184: .SH FILES ! 185: .F core ! 186: .SH "SEE ALSO" ! 187: .IR kill (1), ! 188: .IR setjmp (3), ! 189: .IR stream (4) ! 190: .SH DIAGNOSTICS ! 191: .IR signal : ! 192: .B EINVAL ! 193: .br ! 194: .IR kill : ! 195: .BR EINVAL , ! 196: .BR EPERM , ! 197: .BR ESRCH ! 198: .SH BUGS ! 199: The reason for a trap should be distinguishable by extra arguments ! 200: to the signal handler. ! 201: .br ! 202: If a repeated signal arrives before the last one can be reset, ! 203: there is no chance to catch it. ! 204: .br ! 205: For historical reasons, the return value of ! 206: a catcher function is ! 207: .BR int ; ! 208: it is ! 209: .B void ! 210: in ! 211: .SM ANSI ! 212: standard C.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.