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.\" 30.Dd July 14, 2023 31.Dt PSIGNAL 9 32.Os 33.Sh NAME 34.Nm psignal , 35.Nm kern_psignal , 36.Nm pgsignal , 37.Nm tdsignal 38.Nd post signal to a thread, process, or process group 39.Sh SYNOPSIS 40.In sys/types.h 41.In sys/signalvar.h 42.Ft void 43.Fn kern_psignal "struct proc *p" "int signum" 44.Ft void 45.Fn pgsignal "struct pgrp *pgrp" "int signum" "int checkctty" 46.Ft void 47.Fn tdsignal "struct thread *td" "int signum" 48.Sh DESCRIPTION 49These functions post a signal to a thread or 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 kern_psignal 57function posts signal number 58.Fa signum 59to the process represented by the process structure 60.Fa p . 61The 62.Fn kern_psignal 63function used to be called 64.Fn psignal 65but was renamed in order to eliminate a name collision with the libc 66function of that name and facilitate code reuse. 67With a few exceptions noted below, the target process signal disposition is 68updated and is marked as runnable, so further handling of the signal is done 69in the context of the target process after a context switch. 70Note that 71.Fn kern_psignal 72does not by itself cause a context switch to happen. 73.Pp 74The target process is not marked as runnable in the following cases: 75.Bl -bullet -offset indent 76.It 77The target process is sleeping uninterruptibly. 78The signal will be 79noticed when the process returns from the system call or trap. 80.It 81The target process is currently ignoring the signal. 82.It 83If a stop signal is sent to a sleeping process that takes the 84default action 85(see 86.Xr sigaction 2 ) , 87the process is stopped without awakening it. 88.It 89.Dv SIGCONT 90restarts a stopped process 91(or puts them back to sleep) 92regardless of the signal action 93(e.g., blocked or ignored). 94.El 95.Pp 96If the target process is being traced 97.Fn kern_psignal 98behaves as if the target process were taking the default action for 99.Fa signum . 100This allows the tracing process to be notified of the signal. 101.Pp 102The 103.Fn pgsignal 104function posts signal number 105.Fa signum 106to each member of the process group described by 107.Fa pgrp . 108If 109.Fa checkctty 110is non-zero, the signal will be posted only to processes that have 111a controlling terminal. 112.Fn pgsignal 113is implemented by walking along the process list headed by the field 114.Li pg_members 115of the process group structure 116pointed at by 117.Fa pgrp 118and calling 119.Fn kern_psignal 120as appropriate. 121If 122.Fa pgrp 123is 124.Dv NULL 125no action is taken. 126.Pp 127The 128.Fn tdsignal 129function posts signal number 130.Fa signum 131to the thread represented by the thread structure 132.Fa td . 133.Sh SEE ALSO 134.Xr sigaction 2 , 135.Xr signal 9 , 136.Xr tsleep 9 137.Sh HISTORY 138The 139.Fn psignal 140function was renamed to 141.Fn kern_psignal 142in 143.Fx 9.0 . 144