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