xref: /freebsd/share/man/man9/psignal.9 (revision ea906c4152774dff300bb26fbfc1e4188351c89a)
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$
37.\"
38.Dd June 22, 1996
39.Dt PSIGNAL 9
40.Os
41.Sh NAME
42.Nm psignal ,
43.Nm pgsignal ,
44.Nm gsignal
45.Nd post signal to a process or process group
46.Sh SYNOPSIS
47.In sys/types.h
48.In sys/signalvar.h
49.Ft void
50.Fn psignal "struct proc *p" "int signum"
51.Ft void
52.Fn pgsignal "struct pgrp *pgrp" "int signum" "int checkctty"
53.Ft void
54.Fn gsignal "int pgid" "int signum"
55.Sh DESCRIPTION
56These functions post a signal to one or more processes.
57The argument
58.Fa signum
59common to all three functions should be in the range
60.Bq 1- Ns Dv NSIG .
61.Pp
62The
63.Fn psignal
64function posts signal number
65.Fa signum
66to the process represented by the process structure
67.Fa p .
68With a few exceptions noted below, the target process signal disposition is
69updated and is marked as runnable, so further handling of the signal is done
70in the context of the target process after a context switch.
71Note that
72.Fn psignal
73does not by itself cause a context switch to happen.
74.Pp
75The target process is not marked as runnable in the following cases:
76.Bl -bullet -offset indent
77.It
78The target process is sleeping uninterruptibly.
79The signal will be
80noticed when the process returns from the system call or trap.
81.It
82The target process is currently ignoring the signal.
83.It
84If a stop signal is sent to a sleeping process that takes the
85default action
86(see
87.Xr sigaction 2 ) ,
88the process is stopped without awakening it.
89.It
90.Dv SIGCONT
91restarts a stopped process
92(or puts them back to sleep)
93regardless of the signal action
94(e.g., blocked or ignored).
95.El
96.Pp
97If the target process is being traced
98.Fn psignal
99behaves as if the target process were taking the default action for
100.Fa signum .
101This allows the tracing process to be notified of the signal.
102.Pp
103The
104.Fn pgsignal
105function posts signal number
106.Fa signum
107to each member of the process group described by
108.Fa pgrp .
109If
110.Fa checkctty
111is non-zero, the signal will be posted only to processes that have
112a controlling terminal.
113.Fn pgsignal
114is implemented by walking along the process list headed by the field
115.Li pg_members
116of the process group structure
117pointed at by
118.Fa pgrp
119and calling
120.Fn psignal
121as appropriate.
122If
123.Fa pgrp
124is
125.Dv NULL
126no action is taken.
127.Pp
128The
129.Fn gsignal
130function posts signal number
131.Fa signum
132to each member of the process group identified by the group id
133.Fa pgid .
134.Fn gsignal
135first finds the group structure associated with
136.Fa pgid ,
137then invokes
138.Fn pgsignal
139with the argument
140.Fa checkctty
141set to zero.
142If
143.Fa pgid
144is zero no action is taken.
145.Sh SEE ALSO
146.Xr sigaction 2 ,
147.Xr signal 9 ,
148.Xr tsleep 9
149