1.\" $NetBSD: psignal.9,v 1.1 1996/06/22 22:57:35 pk Exp $ 2.\" 3.\" Copyright (c) 1996 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Paul Kranenburg. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 29.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.\" $FreeBSD$ 38.\" 39.Dd June 22, 1996 40.Dt PSIGNAL 9 41.Os 42.Sh NAME 43.Fd #include <sys/types.h> 44.Fd #include <sys/signalvar.h> 45.Nm psignal , 46.Nm pgsignal , 47.Nm gsignal 48.Nd post signal to a process or process group 49.Sh SYNOPSIS 50.Ft void 51.Fn psignal "struct proc *p" "int signum" 52.Ft void 53.Fn pgsignal "struct pgrp *pgrp" "int signum" "int checkctty" 54.Ft void 55.Fn gsignal "int pgid" "int signum" 56.Sh DESCRIPTION 57These functions post a signal to one or more processes. The argument 58.Fa signum 59common to all three functions should be in the range 60.Bq 1- Ns Dv NSIG . 61.Pp 62The 63.Fn psignal 64function posts signal number 65.Fa signum 66to the process represented by the process structure 67.Fa p . 68With a few exceptions noted below, the target process signal disposition is 69updated and is marked as runnable, so further handling of the signal is done 70in the context of the target process after a context switch. Note that 71.Fn 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. The signal will be 78noticed when the process returns from the system call or trap. 79.It 80The target process is currently ignoring the signal. 81.It 82If a stop signal is sent to a sleeping process that takes the 83default action 84.Pq see Xr sigaction 2 , 85the process is stopped without awakening it. 86.It 87.Dv SIGCONT 88restarts a stopped process 89.Pq or puts them back to sleep 90regardless of the signal action 91.Pq e.g., blocked or ignored . 92.El 93.Pp 94If the target process is being traced 95.Fn psignal 96behaves as if the target process were taking the default action for 97.Fa signum . 98This allows the tracing process to be notified of the signal. 99.Pp 100The 101.Fn pgsignal 102function posts signal number 103.Fa signum 104to each member of the process group described by 105.Fa pgrp . 106If 107.Fa checkctty 108is non-zero, the signal will be posted only to processes that have 109a controlling terminal. 110.Fn pgsignal 111is implemented by walking along the process list headed by the field 112.Li pg_members 113of the process group structure 114pointed at by 115.Fa pgrp 116and calling 117.Fn psignal 118as appropriate. If 119.Fa pgrp 120is 121.Dv NULL 122no action is taken. 123.Pp 124The 125.Fn gsignal 126function posts signal number 127.Fa signum 128to each member of the process group identified by the group id 129.Fa pgid . 130.Fn gsignal 131first finds the group structure associated with 132.Fa pgid , 133then invokes 134.Fn pgsignal 135with the argument 136.Fa checkctty 137set to zero. If 138.Fa pgid 139is zero no action is taken. 140.Sh SEE ALSO 141.Xr sigaction 2 , 142.Xr tsleep 9 143