xref: /freebsd/share/man/man9/psignal.9 (revision b2db760808f74bb53c232900091c9da801ebbfcc)
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.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
20.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26.\" POSSIBILITY OF SUCH DAMAGE.
27.\"
28.\"	$NetBSD: psignal.9,v 1.1 1996/06/22 22:57:35 pk Exp $
29.\" $FreeBSD$
30.\"
31.Dd June 22, 1996
32.Dt PSIGNAL 9
33.Os
34.Sh NAME
35.Nm psignal ,
36.Nm pgsignal ,
37.Nm gsignal
38.Nd post signal to a process or process group
39.Sh SYNOPSIS
40.In sys/types.h
41.In sys/signalvar.h
42.Ft void
43.Fn psignal "struct proc *p" "int signum"
44.Ft void
45.Fn pgsignal "struct pgrp *pgrp" "int signum" "int checkctty"
46.Ft void
47.Fn gsignal "int pgid" "int signum"
48.Sh DESCRIPTION
49These functions post a signal to one or more processes.
50The argument
51.Fa signum
52common to all three functions should be in the range
53.Bq 1- Ns Dv NSIG .
54.Pp
55The
56.Fn psignal
57function posts signal number
58.Fa signum
59to the process represented by the process structure
60.Fa p .
61With a few exceptions noted below, the target process signal disposition is
62updated and is marked as runnable, so further handling of the signal is done
63in the context of the target process after a context switch.
64Note that
65.Fn psignal
66does not by itself cause a context switch to happen.
67.Pp
68The target process is not marked as runnable in the following cases:
69.Bl -bullet -offset indent
70.It
71The target process is sleeping uninterruptibly.
72The signal will be
73noticed when the process returns from the system call or trap.
74.It
75The target process is currently ignoring the signal.
76.It
77If a stop signal is sent to a sleeping process that takes the
78default action
79(see
80.Xr sigaction 2 ) ,
81the process is stopped without awakening it.
82.It
83.Dv SIGCONT
84restarts a stopped process
85(or puts them back to sleep)
86regardless of the signal action
87(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.
115If
116.Fa pgrp
117is
118.Dv NULL
119no action is taken.
120.Pp
121The
122.Fn gsignal
123function posts signal number
124.Fa signum
125to each member of the process group identified by the group id
126.Fa pgid .
127.Fn gsignal
128first finds the group structure associated with
129.Fa pgid ,
130then invokes
131.Fn pgsignal
132with the argument
133.Fa checkctty
134set to zero.
135If
136.Fa pgid
137is zero no action is taken.
138.Sh SEE ALSO
139.Xr sigaction 2 ,
140.Xr signal 9 ,
141.Xr tsleep 9
142