xref: /dflybsd-src/share/man/man9/ksignal.9 (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
2*86d7f5d3SJohn Marino.\" All rights reserved.
3*86d7f5d3SJohn Marino.\"
4*86d7f5d3SJohn Marino.\" This code is derived from software contributed to The NetBSD Foundation
5*86d7f5d3SJohn Marino.\" by Paul Kranenburg.
6*86d7f5d3SJohn Marino.\"
7*86d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without
8*86d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions
9*86d7f5d3SJohn Marino.\" are met:
10*86d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright
11*86d7f5d3SJohn Marino.\"    notice, this list of conditions and the following disclaimer.
12*86d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright
13*86d7f5d3SJohn Marino.\"    notice, this list of conditions and the following disclaimer in the
14*86d7f5d3SJohn Marino.\"    documentation and/or other materials provided with the distribution.
15*86d7f5d3SJohn Marino.\" 3. All advertising materials mentioning features or use of this software
16*86d7f5d3SJohn Marino.\"    must display the following acknowledgement:
17*86d7f5d3SJohn Marino.\"        This product includes software developed by the NetBSD
18*86d7f5d3SJohn Marino.\"        Foundation, Inc. and its contributors.
19*86d7f5d3SJohn Marino.\" 4. Neither the name of The NetBSD Foundation nor the names of its
20*86d7f5d3SJohn Marino.\"    contributors may be used to endorse or promote products derived
21*86d7f5d3SJohn Marino.\"    from this software without specific prior written permission.
22*86d7f5d3SJohn Marino.\"
23*86d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24*86d7f5d3SJohn Marino.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25*86d7f5d3SJohn Marino.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26*86d7f5d3SJohn Marino.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
27*86d7f5d3SJohn Marino.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28*86d7f5d3SJohn Marino.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29*86d7f5d3SJohn Marino.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30*86d7f5d3SJohn Marino.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31*86d7f5d3SJohn Marino.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32*86d7f5d3SJohn Marino.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33*86d7f5d3SJohn Marino.\" POSSIBILITY OF SUCH DAMAGE.
34*86d7f5d3SJohn Marino.\"
35*86d7f5d3SJohn Marino.\"	$NetBSD: psignal.9,v 1.1 1996/06/22 22:57:35 pk Exp $
36*86d7f5d3SJohn Marino.\" $FreeBSD: src/share/man/man9/psignal.9,v 1.7.2.2 2001/12/17 11:30:18 ru Exp $
37*86d7f5d3SJohn Marino.\" $DragonFly: src/share/man/man9/ksignal.9,v 1.3 2007/10/06 22:36:18 swildner Exp $
38*86d7f5d3SJohn Marino.\"
39*86d7f5d3SJohn Marino.Dd June 22, 1996
40*86d7f5d3SJohn Marino.Dt KSIGNAL 9
41*86d7f5d3SJohn Marino.Os
42*86d7f5d3SJohn Marino.Sh NAME
43*86d7f5d3SJohn Marino.Nm ksignal ,
44*86d7f5d3SJohn Marino.Nm pgsignal ,
45*86d7f5d3SJohn Marino.Nm gsignal
46*86d7f5d3SJohn Marino.Nd post signal to a process or process group
47*86d7f5d3SJohn Marino.Sh SYNOPSIS
48*86d7f5d3SJohn Marino.In sys/types.h
49*86d7f5d3SJohn Marino.In sys/signalvar.h
50*86d7f5d3SJohn Marino.Ft void
51*86d7f5d3SJohn Marino.Fn ksignal "struct proc *p" "int signum"
52*86d7f5d3SJohn Marino.Ft void
53*86d7f5d3SJohn Marino.Fn pgsignal "struct pgrp *pgrp" "int signum" "int checkctty"
54*86d7f5d3SJohn Marino.Ft void
55*86d7f5d3SJohn Marino.Fn gsignal "int pgid" "int signum"
56*86d7f5d3SJohn Marino.Sh DESCRIPTION
57*86d7f5d3SJohn MarinoThese functions post a signal to one or more processes.
58*86d7f5d3SJohn MarinoThe argument
59*86d7f5d3SJohn Marino.Fa signum
60*86d7f5d3SJohn Marinocommon to all three functions should be in the range
61*86d7f5d3SJohn Marino.Bq 1- Ns Dv NSIG .
62*86d7f5d3SJohn Marino.Pp
63*86d7f5d3SJohn MarinoThe
64*86d7f5d3SJohn Marino.Fn ksignal
65*86d7f5d3SJohn Marinofunction posts signal number
66*86d7f5d3SJohn Marino.Fa signum
67*86d7f5d3SJohn Marinoto the process represented by the process structure
68*86d7f5d3SJohn Marino.Fa p .
69*86d7f5d3SJohn MarinoWith a few exceptions noted below, the target process signal disposition is
70*86d7f5d3SJohn Marinoupdated and is marked as runnable, so further handling of the signal is done
71*86d7f5d3SJohn Marinoin the context of the target process after a context switch.
72*86d7f5d3SJohn MarinoNote that
73*86d7f5d3SJohn Marino.Fn ksignal
74*86d7f5d3SJohn Marinodoes not by itself cause a context switch to happen.
75*86d7f5d3SJohn Marino.Pp
76*86d7f5d3SJohn MarinoThe target process is not marked as runnable in the following cases:
77*86d7f5d3SJohn Marino.Bl -bullet -offset indent
78*86d7f5d3SJohn Marino.It
79*86d7f5d3SJohn MarinoThe target process is sleeping uninterruptibly.
80*86d7f5d3SJohn MarinoThe signal will be
81*86d7f5d3SJohn Marinonoticed when the process returns from the system call or trap.
82*86d7f5d3SJohn Marino.It
83*86d7f5d3SJohn MarinoThe target process is currently ignoring the signal.
84*86d7f5d3SJohn Marino.It
85*86d7f5d3SJohn MarinoIf a stop signal is sent to a sleeping process that takes the
86*86d7f5d3SJohn Marinodefault action
87*86d7f5d3SJohn Marino(see
88*86d7f5d3SJohn Marino.Xr sigaction 2 ) ,
89*86d7f5d3SJohn Marinothe process is stopped without awakening it.
90*86d7f5d3SJohn Marino.It
91*86d7f5d3SJohn Marino.Dv SIGCONT
92*86d7f5d3SJohn Marinorestarts a stopped process
93*86d7f5d3SJohn Marino(or puts them back to sleep)
94*86d7f5d3SJohn Marinoregardless of the signal action
95*86d7f5d3SJohn Marino(e.g., blocked or ignored).
96*86d7f5d3SJohn Marino.El
97*86d7f5d3SJohn Marino.Pp
98*86d7f5d3SJohn MarinoIf the target process is being traced
99*86d7f5d3SJohn Marino.Fn ksignal
100*86d7f5d3SJohn Marinobehaves as if the target process were taking the default action for
101*86d7f5d3SJohn Marino.Fa signum .
102*86d7f5d3SJohn MarinoThis allows the tracing process to be notified of the signal.
103*86d7f5d3SJohn Marino.Pp
104*86d7f5d3SJohn MarinoThe
105*86d7f5d3SJohn Marino.Fn pgsignal
106*86d7f5d3SJohn Marinofunction posts signal number
107*86d7f5d3SJohn Marino.Fa signum
108*86d7f5d3SJohn Marinoto each member of the process group described by
109*86d7f5d3SJohn Marino.Fa pgrp .
110*86d7f5d3SJohn MarinoIf
111*86d7f5d3SJohn Marino.Fa checkctty
112*86d7f5d3SJohn Marinois non-zero, the signal will be posted only to processes that have
113*86d7f5d3SJohn Marinoa controlling terminal.
114*86d7f5d3SJohn Marino.Fn pgsignal
115*86d7f5d3SJohn Marinois implemented by walking along the process list headed by the field
116*86d7f5d3SJohn Marino.Li pg_members
117*86d7f5d3SJohn Marinoof the process group structure
118*86d7f5d3SJohn Marinopointed at by
119*86d7f5d3SJohn Marino.Fa pgrp
120*86d7f5d3SJohn Marinoand calling
121*86d7f5d3SJohn Marino.Fn ksignal
122*86d7f5d3SJohn Marinoas appropriate.
123*86d7f5d3SJohn MarinoIf
124*86d7f5d3SJohn Marino.Fa pgrp
125*86d7f5d3SJohn Marinois
126*86d7f5d3SJohn Marino.Dv NULL
127*86d7f5d3SJohn Marinono action is taken.
128*86d7f5d3SJohn Marino.Pp
129*86d7f5d3SJohn MarinoThe
130*86d7f5d3SJohn Marino.Fn gsignal
131*86d7f5d3SJohn Marinofunction posts signal number
132*86d7f5d3SJohn Marino.Fa signum
133*86d7f5d3SJohn Marinoto each member of the process group identified by the group id
134*86d7f5d3SJohn Marino.Fa pgid .
135*86d7f5d3SJohn Marino.Fn gsignal
136*86d7f5d3SJohn Marinofirst finds the group structure associated with
137*86d7f5d3SJohn Marino.Fa pgid ,
138*86d7f5d3SJohn Marinothen invokes
139*86d7f5d3SJohn Marino.Fn pgsignal
140*86d7f5d3SJohn Marinowith the argument
141*86d7f5d3SJohn Marino.Fa checkctty
142*86d7f5d3SJohn Marinoset to zero.
143*86d7f5d3SJohn MarinoIf
144*86d7f5d3SJohn Marino.Fa pgid
145*86d7f5d3SJohn Marinois zero no action is taken.
146*86d7f5d3SJohn Marino.Sh SEE ALSO
147*86d7f5d3SJohn Marino.Xr sigaction 2 ,
148*86d7f5d3SJohn Marino.Xr tsleep 9
149