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