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