1*8269e767SBrooks Davis.\" Copyright (c) 1980, 1991, 1993 2*8269e767SBrooks Davis.\" The Regents of the University of California. All rights reserved. 3*8269e767SBrooks Davis.\" 4*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without 5*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions 6*8269e767SBrooks Davis.\" are met: 7*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright 8*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer. 9*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright 10*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer in the 11*8269e767SBrooks Davis.\" documentation and/or other materials provided with the distribution. 12*8269e767SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors 13*8269e767SBrooks Davis.\" may be used to endorse or promote products derived from this software 14*8269e767SBrooks Davis.\" without specific prior written permission. 15*8269e767SBrooks Davis.\" 16*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17*8269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*8269e767SBrooks Davis.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20*8269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*8269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*8269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*8269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*8269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*8269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*8269e767SBrooks Davis.\" SUCH DAMAGE. 27*8269e767SBrooks Davis.\" 28*8269e767SBrooks Davis.Dd December 1, 2019 29*8269e767SBrooks Davis.Dt KILL 2 30*8269e767SBrooks Davis.Os 31*8269e767SBrooks Davis.Sh NAME 32*8269e767SBrooks Davis.Nm kill 33*8269e767SBrooks Davis.Nd send signal to a process 34*8269e767SBrooks Davis.Sh LIBRARY 35*8269e767SBrooks Davis.Lb libc 36*8269e767SBrooks Davis.Sh SYNOPSIS 37*8269e767SBrooks Davis.In sys/types.h 38*8269e767SBrooks Davis.In signal.h 39*8269e767SBrooks Davis.Ft int 40*8269e767SBrooks Davis.Fn kill "pid_t pid" "int sig" 41*8269e767SBrooks Davis.Sh DESCRIPTION 42*8269e767SBrooks DavisThe 43*8269e767SBrooks Davis.Fn kill 44*8269e767SBrooks Davissystem call sends the signal given by 45*8269e767SBrooks Davis.Fa sig 46*8269e767SBrooks Davisto 47*8269e767SBrooks Davis.Fa pid , 48*8269e767SBrooks Davisa 49*8269e767SBrooks Davisprocess or a group of processes. 50*8269e767SBrooks DavisThe 51*8269e767SBrooks Davis.Fa sig 52*8269e767SBrooks Davisargument 53*8269e767SBrooks Davismay be one of the signals specified in 54*8269e767SBrooks Davis.Xr sigaction 2 55*8269e767SBrooks Davisor it may be 0, in which case 56*8269e767SBrooks Daviserror checking is performed but no 57*8269e767SBrooks Davissignal is actually sent. 58*8269e767SBrooks DavisThis can be used to check the validity of 59*8269e767SBrooks Davis.Fa pid . 60*8269e767SBrooks Davis.Pp 61*8269e767SBrooks DavisFor a process to have permission to send a signal to a process designated 62*8269e767SBrooks Davisby 63*8269e767SBrooks Davis.Fa pid , 64*8269e767SBrooks Davisthe user must be the super-user, or 65*8269e767SBrooks Davisthe real or saved user ID of the receiving process must match 66*8269e767SBrooks Davisthe real or effective user ID of the sending process. 67*8269e767SBrooks DavisA single exception is the signal SIGCONT, which may always be sent 68*8269e767SBrooks Davisto any process with the same session ID as the sender. 69*8269e767SBrooks DavisIn addition, if the 70*8269e767SBrooks Davis.Va security.bsd.conservative_signals 71*8269e767SBrooks Davis.Xr sysctl 9 72*8269e767SBrooks Davisis set to 1, the user is not a super-user, and 73*8269e767SBrooks Davisthe receiver is set-uid, then 74*8269e767SBrooks Davisonly job control and terminal control signals may 75*8269e767SBrooks Davisbe sent (in particular, only SIGKILL, SIGINT, SIGTERM, SIGALRM, 76*8269e767SBrooks DavisSIGSTOP, SIGTTIN, SIGTTOU, SIGTSTP, SIGHUP, SIGUSR1, SIGUSR2). 77*8269e767SBrooks Davis.Bl -tag -width Ds 78*8269e767SBrooks Davis.It \&If Fa pid No \&is greater than zero : 79*8269e767SBrooks DavisThe 80*8269e767SBrooks Davis.Fa sig 81*8269e767SBrooks Davissignal 82*8269e767SBrooks Davisis sent to the process whose ID is equal to 83*8269e767SBrooks Davis.Fa pid . 84*8269e767SBrooks Davis.It \&If Fa pid No \&is zero : 85*8269e767SBrooks DavisThe 86*8269e767SBrooks Davis.Fa sig 87*8269e767SBrooks Davissignal 88*8269e767SBrooks Davisis sent to all processes whose group ID is equal 89*8269e767SBrooks Davisto the process group ID of the sender, and for which the 90*8269e767SBrooks Davisprocess has permission; 91*8269e767SBrooks Davisthis is a variant of 92*8269e767SBrooks Davis.Xr killpg 2 . 93*8269e767SBrooks Davis.It \&If Fa pid No \&is -1 : 94*8269e767SBrooks DavisIf the user has super-user privileges, 95*8269e767SBrooks Davisthe signal is sent to all processes excluding 96*8269e767SBrooks Davissystem processes 97*8269e767SBrooks Davis(with 98*8269e767SBrooks Davis.Dv P_SYSTEM 99*8269e767SBrooks Davisflag set), 100*8269e767SBrooks Davisprocess with ID 1 101*8269e767SBrooks Davis(usually 102*8269e767SBrooks Davis.Xr init 8 ) , 103*8269e767SBrooks Davisand the process sending the signal. 104*8269e767SBrooks DavisIf the user is not the super user, the signal is sent to all processes 105*8269e767SBrooks Daviswhich the caller has permissions to, excluding the process sending the signal. 106*8269e767SBrooks DavisNo error is returned if any process could be signaled. 107*8269e767SBrooks Davis.El 108*8269e767SBrooks Davis.Pp 109*8269e767SBrooks DavisIf the process number is negative but not -1, 110*8269e767SBrooks Davisthe signal is sent to all processes whose process group ID 111*8269e767SBrooks Davisis equal to the absolute value of the process number. 112*8269e767SBrooks DavisThis is a variant of 113*8269e767SBrooks Davis.Xr killpg 2 . 114*8269e767SBrooks Davis.Sh RETURN VALUES 115*8269e767SBrooks Davis.Rv -std kill 116*8269e767SBrooks Davis.Sh ERRORS 117*8269e767SBrooks DavisThe 118*8269e767SBrooks Davis.Fn kill 119*8269e767SBrooks Davissystem call 120*8269e767SBrooks Daviswill fail and no signal will be sent if: 121*8269e767SBrooks Davis.Bl -tag -width Er 122*8269e767SBrooks Davis.It Bq Er EINVAL 123*8269e767SBrooks DavisThe 124*8269e767SBrooks Davis.Fa sig 125*8269e767SBrooks Davisargument 126*8269e767SBrooks Davisis not a valid signal number. 127*8269e767SBrooks Davis.It Bq Er ESRCH 128*8269e767SBrooks DavisNo process or process group can be found corresponding to that specified by 129*8269e767SBrooks Davis.Fa pid . 130*8269e767SBrooks Davis.It Bq Er EPERM 131*8269e767SBrooks DavisThe sending process does not have permission to send 132*8269e767SBrooks Davis.Va sig 133*8269e767SBrooks Davisto any receiving process. 134*8269e767SBrooks Davis.El 135*8269e767SBrooks Davis.Sh SEE ALSO 136*8269e767SBrooks Davis.Xr getpgrp 2 , 137*8269e767SBrooks Davis.Xr getpid 2 , 138*8269e767SBrooks Davis.Xr killpg 2 , 139*8269e767SBrooks Davis.Xr sigaction 2 , 140*8269e767SBrooks Davis.Xr sigqueue 2 , 141*8269e767SBrooks Davis.Xr raise 3 , 142*8269e767SBrooks Davis.Xr init 8 143*8269e767SBrooks Davis.Sh STANDARDS 144*8269e767SBrooks DavisThe 145*8269e767SBrooks Davis.Fn kill 146*8269e767SBrooks Davissystem call is expected to conform to 147*8269e767SBrooks Davis.St -p1003.1-90 . 148*8269e767SBrooks Davis.Sh HISTORY 149*8269e767SBrooks DavisA version of the 150*8269e767SBrooks Davis.Fn kill 151*8269e767SBrooks Davisfunction appeared in 152*8269e767SBrooks Davis.At v3 . 153*8269e767SBrooks DavisThe signal number was added to the 154*8269e767SBrooks Davis.Fn kill 155*8269e767SBrooks Davisfunction in 156*8269e767SBrooks Davis.At v4 . 157