diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-09-15 05:46:15 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-09-15 05:46:15 +0000 |
commit | 4223257a8ea3bf3b20d2cf21f072bd177760544f (patch) | |
tree | 6532386e0576b15fe9634504cd162cd741224b91 /lib/libc | |
parent | 888e160939afae5514e1c6d0a7f2dc2d295c0fc5 (diff) |
From FreeBSD (joerg@freebsd.org):
Implement SA_NOCLDWAIT by reparenting kids of processes that have
the appropriate bit set to PID 1, and let PID 1 handle the zombie.
This assumes that PID 1 will wait for its kids (which is true of init).
This also includes some FreeBSD sigaction.2.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/sys/sigaction.2 | 116 |
1 files changed, 74 insertions, 42 deletions
diff --git a/lib/libc/sys/sigaction.2 b/lib/libc/sys/sigaction.2 index 8d90440a2be..9c0143a2002 100644 --- a/lib/libc/sys/sigaction.2 +++ b/lib/libc/sys/sigaction.2 @@ -43,9 +43,9 @@ .Fd #include <signal.h> .Bd -literal struct sigaction { - void (*sa_handler)(); - sigset_t sa_mask; - int sa_flags; + void (*sa_handler)(); /* signal handler */ + sigset_t sa_mask; /* signal mask to apply */ + int sa_flags; /* see signal options below */ }; .Ed .Ft int @@ -53,10 +53,10 @@ struct sigaction { .Sh DESCRIPTION The system defines a set of signals that may be delivered to a process. Signal delivery resembles the occurrence of a hardware interrupt: -the signal is blocked from further occurrence, the current process +the signal is normally blocked from further occurrence, the current process context is saved, and a new one is built. A process may specify a .Em handler -to which a signal is delivered, or specify that a signal is to be +to which a signal is delivered, or specify that a signal is to be .Em ignored . A process may also specify that a default action is to be taken by the system when a signal occurs. @@ -71,11 +71,11 @@ of the process. This may be changed, on a per-handler basis, so that signals are taken on a special .Em "signal stack" . .Pp -Signal routines execute with the signal that caused their +Signal routines normally execute with the signal that caused their invocation .Em blocked , but other signals may yet occur. -A global +A global .Em "signal mask" defines the set of signals currently blocked from delivery to a process. The signal mask for a process is initialized @@ -102,7 +102,7 @@ The set of pending signals is returned by the function. When a caught signal is delivered, the current state of the process is saved, -a new signal mask is calculated (as described below), +a new signal mask is calculated (as described below), and the signal handler is invoked. The call to the handler is arranged so that if the signal handling routine returns normally the process will resume execution in the context @@ -116,11 +116,12 @@ installed for the duration of the process' signal handler .Xr sigprocmask call is made). This mask is formed by taking the union of the current signal mask set, -the signal to be delivered, and +the signal to be delivered, and the signal mask associated with the handler to be invoked. .Pp .Fn Sigaction -assigns an action for a specific signal. +assigns an action for a signal specified by +.Fa sig . If .Fa act is non-zero, it @@ -129,15 +130,15 @@ specifies an action .Dv SIG_IGN , or a handler routine) and mask to be used when delivering the specified signal. -If +If .Fa oact is non-zero, the previous handling information for the signal is returned to the user. .Pp -Once a signal handler is installed, it remains installed +Once a signal handler is installed, it normally remains installed until another .Fn sigaction -call is made, or an +call is made, or an .Xr execve 2 is performed. A signal-specific default action may be reset by @@ -164,9 +165,10 @@ of the signal are ignored and discarded. .Pp Options may be specified by setting .Em sa_flags . -If the -.Dv SA_NOCLDSTOP -bit is set when installing a catching function +The meaning of the various bits is as follows: +.Bl -tag -offset indent -width SA_RESETHANDXX +.It Dv SA_NOCLDSTOP +If this bit is set when installing a catching function for the .Dv SIGCHLD signal, @@ -174,28 +176,44 @@ the .Dv SIGCHLD signal will be generated only when a child process exits, not when a child process stops. -Further, if the -.Dv SA_ONSTACK -bit is set in -.Em sa_flags , -the system will deliver the signal to the process on a +.It Dv SA_NOCLDWAIT +If this bit is set when calling +.Fn sigaction +for the +.Dv SIGCHLD +signal, the system will not create zombie processes when children of +the calling process exit. If the calling process subsequently issues +a +.Xr wait 2 +(or equivalent), it blocks until all of the calling process's child +processes terminate, and then returns a value of -1 with errno set to +.Dv ECHILD . +.It Dv SA_ONSTACK +If this bit is set, the system will deliver the signal to the process +on a .Em "signal stack" , specified with -.Xr sigstack 2 . -.Pp -Finally, the -.Dv SA_SIGINFO -option causes the 2nd argument for the signal handler to be a pointer -to a +.Xr sigaltstack 2 . +.It Dv SA_NODEFER +If this bit is set, further occurrences of the delivered signal are +not masked during the execution of the handler. +.It Dv SA_RESETHAND +If this bit is set, the handler is reset back to +.Dv SIG_DFL +at the moment the signal is delivered. +.It Dv SA_SIGINFO +If this bit is set, the 2nd argument of the handler is set to +be a pointer to a .Em siginfo_t -as described in +structure as described in .Pa <sys/siginfo.h> . The .Em siginfo_t -is a part of +structure is a part of .St -p1003.1b . -and provides much more information about the causes and +It provides much more information about the causes and attributes of the signal that is being delivered. +.El .Pp If a signal is caught during the system calls listed below, the call may be forced to terminate @@ -229,7 +247,7 @@ but instead return a partial success (for example, a short read count). After a .Xr fork 2 or -.Xr vfork 2 +.Xr vfork 2 , all signals, the signal mask, the signal stack, and the restart/interrupt flags are inherited by the child. .Pp @@ -251,7 +269,7 @@ with names as in the include file .It Dv SIGQUIT No " create core image" " quit program" .It Dv SIGILL No " create core image" " illegal instruction" .It Dv SIGTRAP No " create core image" " trace trap" -.It Dv SIGABRT No " create core image" Xr abort 2 +.It Dv SIGABRT No " create core image" Xr abort 3 call (formerly .Dv SIGIOT ) .It Dv SIGEMT No " create core image" " emulate instruction executed" @@ -287,13 +305,15 @@ is possible on a descriptor (see .It Dv SIGUSR2 No " terminate process" " User defined signal 2" .El .Sh NOTE -The mask specified in +The +.Fa sa_mask +field specified in .Fa act is not allowed to block .Dv SIGKILL or .Dv SIGSTOP . -This is done silently by the system. +Any attempt to do so will be silently ignored. .Sh RETURN VALUES A 0 value indicated that the call succeeded. A \-1 return value indicates an error occurred and @@ -337,7 +357,7 @@ of the following occurs: .It Bq Er EFAULT Either .Fa act -or +or .Fa oact points to memory that is not a valid part of the process address space. @@ -360,7 +380,7 @@ The and .Dv SA_RESTART flags are Berkeley extensions, -as are the signals, +as are the signals .Dv SIGTRAP , .Dv SIGEMT , .Dv SIGBUS , @@ -377,18 +397,30 @@ and Those signals are available on most .Tn BSD Ns \-derived systems. +The +.Dv SA_NODEFER +and +.Dv SA_RESETHAND +flags are intended for backwards compatability with other operating +systems. The +.Dv SA_NOCLDSTOP , +.Dv SA_NOCLDWAIT , +and +.Dv SA_SIGINFO +flags are options commonly found in other operating systems. .Sh SEE ALSO .Xr kill 1 , -.Xr ptrace 2 , .Xr kill 2 , -.Xr sigprocmask 2 , -.Xr sigsuspend 2 , +.Xr ptrace 2 , +.Xr sigaltstack 2 , .Xr sigblock 2 , -.Xr sigsetmask 2 , .Xr sigpause 2 , -.Xr sigstack 2 , -.Xr sigvec 3 , +.Xr sigprocmask 2 , +.Xr sigsetmask 2 , +.Xr sigsuspend 2 , +.Xr wait 2 , .Xr setjmp 3 , .Xr siginterrupt 3 , .Xr sigsetops 3 , +.Xr sigvec 3 , .Xr tty 4 |