1.\" $NetBSD: kill.2,v 1.23 2014/07/15 17:39:21 wiz Exp $ 2.\" 3.\" Copyright (c) 1980, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" @(#)kill.2 8.3 (Berkeley) 4/19/94 31.\" 32.Dd July 9, 2014 33.Dt KILL 2 34.Os 35.Sh NAME 36.Nm kill 37.Nd send signal to a process 38.Sh LIBRARY 39.Lb libc 40.Sh SYNOPSIS 41.In signal.h 42.Ft int 43.Fn kill "pid_t pid" "int sig" 44.Sh DESCRIPTION 45The 46.Fn kill 47function sends the signal given by 48.Fa sig 49to 50.Fa pid , 51a 52process or a group of processes. 53.Fa sig 54may be one of the signals specified in 55.Xr sigaction 2 56or it may be 0, in which case 57error checking is performed but no 58signal is actually sent. 59This can be used to check the validity of 60.Fa pid . 61.Pp 62For a process to have permission to send a signal to a process designated 63by 64.Fa pid , 65the real or effective user ID of the receiving process must match 66that of the sending process or the user must have appropriate privileges 67(such as given by a set-user-ID program or the user is the super-user). 68A single exception is the signal SIGCONT, which may always be sent 69to any descendant of the current process. 70.Bl -tag -width Ds 71.It \&If Fa pid No \&is greater than zero : 72.Fa sig 73is sent to the process whose ID is equal to 74.Fa pid . 75.It \&If Fa pid No \&is zero : 76.Fa sig 77is sent to all processes whose process group ID is equal 78to the process group ID of the sender, and for which the 79process has permission; 80this is a variant of 81.Xr killpg 3 . 82.It \&If Fa pid No \&is \-1 : 83If the user has super-user privileges, 84the signal is sent to all processes excluding 85system processes and the process sending the signal. 86If the user is not the super user, the signal is sent to all processes 87with the same uid as the user excluding the process sending the signal. 88No error is returned if any process could be signaled. 89.El 90.Pp 91For compatibility with System V, 92if the process number is negative but not \-1, 93the signal is sent to all processes whose process group ID 94is equal to the absolute value of the process number. 95This is a variant of 96.Xr killpg 3 . 97.Pp 98If 99.Fa sig 100is equal to 101.Dv 0 , 102then no signal is sent to the process ID or process group ID, but error 103checking is performed. 104This can be used to check if the process ID or process group ID exist. 105.Sh RETURN VALUES 106Upon successful completion, a value of 0 is returned. 107Otherwise, a value of \-1 is returned and 108.Va errno 109is set to indicate the error. 110.Sh ERRORS 111.Fn kill 112will fail and no signal will be sent if: 113.Bl -tag -width Er 114.It Bq Er EINVAL 115.Fa sig 116is not a valid signal number. 117.It Bq Er EPERM 118The sending process is not the super-user and its effective 119user id does not match the effective user-id of the receiving process. 120When signaling a process group, this error is returned if any members 121of the group could not be signaled. 122.It Bq Er ESRCH 123No process can be found corresponding to that specified by 124.Fa pid ; 125or the process id was given as 0 126but the sending process does not have a process group. 127.El 128.Sh SEE ALSO 129.Xr getpgrp 2 , 130.Xr getpid 2 , 131.Xr sigaction 2 , 132.Xr killpg 3 , 133.Xr signal 7 134.Sh STANDARDS 135The 136.Fn kill 137function is expected to conform to 138.St -p1003.1-90 . 139