xref: /openbsd-src/share/man/man9/psignal.9 (revision 41ce3b17e73f6b7d2d9e1a3d961e4bab2d895cb5)
1*41ce3b17Snaddy.\"	$OpenBSD: psignal.9,v 1.8 2022/03/31 17:27:23 naddy Exp $
28545c142Sespie.\"	$NetBSD: psignal.9,v 1.5 1999/03/16 00:40:47 garbled Exp $
38545c142Sespie.\"
48545c142Sespie.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
58545c142Sespie.\" All rights reserved.
68545c142Sespie.\"
78545c142Sespie.\" This code is derived from software contributed to The NetBSD Foundation
88545c142Sespie.\" by Paul Kranenburg.
98545c142Sespie.\"
108545c142Sespie.\" Redistribution and use in source and binary forms, with or without
118545c142Sespie.\" modification, are permitted provided that the following conditions
128545c142Sespie.\" are met:
138545c142Sespie.\" 1. Redistributions of source code must retain the above copyright
148545c142Sespie.\"    notice, this list of conditions and the following disclaimer.
158545c142Sespie.\" 2. Redistributions in binary form must reproduce the above copyright
168545c142Sespie.\"    notice, this list of conditions and the following disclaimer in the
178545c142Sespie.\"    documentation and/or other materials provided with the distribution.
188545c142Sespie.\"
198545c142Sespie.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
208545c142Sespie.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
218545c142Sespie.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
228545c142Sespie.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
238545c142Sespie.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
248545c142Sespie.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
258545c142Sespie.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
268545c142Sespie.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
278545c142Sespie.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
288545c142Sespie.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
298545c142Sespie.\" POSSIBILITY OF SUCH DAMAGE.
308545c142Sespie.\"
31*41ce3b17Snaddy.Dd $Mdocdate: March 31 2022 $
328545c142Sespie.Dt PSIGNAL 9
338545c142Sespie.Os
348545c142Sespie.Sh NAME
358545c142Sespie.Nm psignal ,
368545c142Sespie.Nm pgsignal ,
37dad4761dSvisa.Nm pgsigio
388545c142Sespie.Nd post signal to a process
398545c142Sespie.Sh SYNOPSIS
408545c142Sespie.Ft void
415dfee228Sschwarze.Fn psignal "struct proc *p" "int signum"
428545c142Sespie.Ft void
435dfee228Sschwarze.Fn pgsignal "struct pgrp *pgrp" "int signum" "int checkctty"
448545c142Sespie.Ft void
45685c0417Svisa.Fn pgsigio "struct sigio_ref *sir" "int sigum" "int checkctty"
468545c142Sespie.Sh DESCRIPTION
478545c142SespieThese functions post a signal to one or more processes.
488545c142SespieThe argument
498545c142Sespie.Fa signum
508545c142Sespiecommon to all three functions should be in the range
518545c142Sespie.Bq 1- Ns Dv NSIG .
528545c142Sespie.Pp
538545c142SespieThe
548545c142Sespie.Fn psignal
558545c142Sespiefunction posts signal number
568545c142Sespie.Fa signum
578545c142Sespieto the process represented by the process structure
588545c142Sespie.Fa p .
598545c142SespieWith a few exceptions noted below, the target process signal disposition is
608545c142Sespieupdated and is marked as runnable, so further handling of the signal is done
618545c142Sespiein the context of the target process after a context switch.
628545c142SespieNote that
638545c142Sespie.Fn psignal
648545c142Sespiedoes not by itself cause a context switch to happen.
658545c142Sespie.Pp
668545c142SespieThe target process is not marked as runnable in the following cases:
678545c142Sespie.Bl -bullet -offset indent
688545c142Sespie.It
698545c142SespieThe target process is sleeping uninterruptibly.
708545c142SespieThe signal will be
718545c142Sespienoticed when the process returns from the system call or trap.
728545c142Sespie.It
738545c142SespieThe target process is currently ignoring the signal.
748545c142Sespie.It
758545c142SespieIf a stop signal is sent to a sleeping process that takes the
768545c142Sespiedefault action
778545c142Sespie.Pq see Xr sigaction 2 ,
788545c142Sespiethe process is stopped without awakening it.
798545c142Sespie.It
808545c142Sespie.Dv SIGCONT
818545c142Sespierestarts a stopped process
828545c142Sespie.Pq or puts them back to sleep
838545c142Sespieregardless of the signal action
848545c142Sespie.Pq e.g., blocked or ignored .
858545c142Sespie.El
868545c142Sespie.Pp
878545c142SespieIf the target process is being traced,
888545c142Sespie.Fn psignal
898545c142Sespiebehaves as if the target process were taking the default action for
908545c142Sespie.Fa signum .
918545c142SespieThis allows the tracing process to be notified of the signal.
928545c142Sespie.Pp
938545c142SespieThe
948545c142Sespie.Fn pgsignal
958545c142Sespiefunction posts signal number
968545c142Sespie.Fa signum
978545c142Sespieto each member of the process group described by
988545c142Sespie.Fa pgrp .
998545c142SespieIf
1008545c142Sespie.Fa checkctty
1018545c142Sespieis non-zero, the signal will be posted only to processes that have
1028545c142Sespiea controlling terminal.
1038545c142SespieIf
1048545c142Sespie.Fa pgrp
1058545c142Sespieis
106*41ce3b17Snaddy.Dv NULL ,
1078545c142Sespieno action is taken.
1088545c142Sespie.Pp
1098545c142SespieThe
110685c0417Svisa.Fn pgsigio
111685c0417Svisafunction posts signal number
112685c0417Svisa.Fa signum
113685c0417Svisato the process or each member of the process group indicated by reference
114685c0417Svisa.Fa sir .
115685c0417SvisaIf
116685c0417Svisa.Fa checkctty
117685c0417Svisais non-zero, the signal will be posted only to processes that have
118685c0417Svisaa controlling terminal.
1198545c142Sespie.Sh CODE REFERENCES
120657686c6SespieThese functions are implemented in the file
121657686c6Sespie.Pa sys/kern/kern_sig.c .
1228545c142Sespie.Sh SEE ALSO
1238545c142Sespie.Xr sigaction 2 ,
124685c0417Svisa.Xr sigio_setown 9 ,
1258545c142Sespie.Xr tsleep 9
126