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