1.\" $OpenBSD: psignal.9,v 1.7 2018/12/17 14:51:57 visa Exp $ 2.\" $NetBSD: psignal.9,v 1.5 1999/03/16 00:40:47 garbled Exp $ 3.\" 4.\" Copyright (c) 1996 The NetBSD Foundation, Inc. 5.\" All rights reserved. 6.\" 7.\" This code is derived from software contributed to The NetBSD Foundation 8.\" by Paul Kranenburg. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29.\" POSSIBILITY OF SUCH DAMAGE. 30.\" 31.Dd $Mdocdate: December 17 2018 $ 32.Dt PSIGNAL 9 33.Os 34.Sh NAME 35.Nm psignal , 36.Nm pgsignal , 37.Nm pgsigio 38.Nd post signal to a process 39.Sh SYNOPSIS 40.Ft void 41.Fn psignal "struct proc *p" "int signum" 42.Ft void 43.Fn pgsignal "struct pgrp *pgrp" "int signum" "int checkctty" 44.Ft void 45.Fn pgsigio "struct sigio_ref *sir" "int sigum" "int checkctty" 46.Sh DESCRIPTION 47These functions post a signal to one or more processes. 48The argument 49.Fa signum 50common to all three functions should be in the range 51.Bq 1- Ns Dv NSIG . 52.Pp 53The 54.Fn psignal 55function posts signal number 56.Fa signum 57to the process represented by the process structure 58.Fa p . 59With a few exceptions noted below, the target process signal disposition is 60updated and is marked as runnable, so further handling of the signal is done 61in the context of the target process after a context switch. 62Note that 63.Fn psignal 64does not by itself cause a context switch to happen. 65.Pp 66The target process is not marked as runnable in the following cases: 67.Bl -bullet -offset indent 68.It 69The target process is sleeping uninterruptibly. 70The signal will be 71noticed when the process returns from the system call or trap. 72.It 73The target process is currently ignoring the signal. 74.It 75If a stop signal is sent to a sleeping process that takes the 76default action 77.Pq see Xr sigaction 2 , 78the process is stopped without awakening it. 79.It 80.Dv SIGCONT 81restarts a stopped process 82.Pq or puts them back to sleep 83regardless of the signal action 84.Pq e.g., blocked or ignored . 85.El 86.Pp 87If the target process is being traced, 88.Fn psignal 89behaves as if the target process were taking the default action for 90.Fa signum . 91This allows the tracing process to be notified of the signal. 92.Pp 93The 94.Fn pgsignal 95function posts signal number 96.Fa signum 97to each member of the process group described by 98.Fa pgrp . 99If 100.Fa checkctty 101is non-zero, the signal will be posted only to processes that have 102a controlling terminal. 103If 104.Fa pgrp 105is 106.Dv NULL 107no action is taken. 108.Pp 109The 110.Fn pgsigio 111function posts signal number 112.Fa signum 113to the process or each member of the process group indicated by reference 114.Fa sir . 115If 116.Fa checkctty 117is non-zero, the signal will be posted only to processes that have 118a controlling terminal. 119.Sh CODE REFERENCES 120These functions are implemented in the file 121.Pa sys/kern/kern_sig.c . 122.Sh SEE ALSO 123.Xr sigaction 2 , 124.Xr sigio_setown 9 , 125.Xr tsleep 9 126