xref: /minix3/lib/libc/sys/kill.2 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: kill.2,v 1.23 2014/07/15 17:39:21 wiz Exp $
22fe8fb19SBen Gras.\"
32fe8fb19SBen Gras.\" Copyright (c) 1980, 1991, 1993
42fe8fb19SBen Gras.\"	The Regents of the University of California.  All rights reserved.
52fe8fb19SBen Gras.\"
62fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
72fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
82fe8fb19SBen Gras.\" are met:
92fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
102fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
112fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
122fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
132fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
142fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors
152fe8fb19SBen Gras.\"    may be used to endorse or promote products derived from this software
162fe8fb19SBen Gras.\"    without specific prior written permission.
172fe8fb19SBen Gras.\"
182fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
192fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
202fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
212fe8fb19SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
222fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
232fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
242fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
252fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
262fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
272fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
282fe8fb19SBen Gras.\" SUCH DAMAGE.
292fe8fb19SBen Gras.\"
302fe8fb19SBen Gras.\"     @(#)kill.2	8.3 (Berkeley) 4/19/94
312fe8fb19SBen Gras.\"
32*0a6a1f1dSLionel Sambuc.Dd July 9, 2014
332fe8fb19SBen Gras.Dt KILL 2
342fe8fb19SBen Gras.Os
352fe8fb19SBen Gras.Sh NAME
362fe8fb19SBen Gras.Nm kill
372fe8fb19SBen Gras.Nd send signal to a process
382fe8fb19SBen Gras.Sh LIBRARY
392fe8fb19SBen Gras.Lb libc
402fe8fb19SBen Gras.Sh SYNOPSIS
412fe8fb19SBen Gras.In signal.h
422fe8fb19SBen Gras.Ft int
432fe8fb19SBen Gras.Fn kill "pid_t pid" "int sig"
442fe8fb19SBen Gras.Sh DESCRIPTION
452fe8fb19SBen GrasThe
462fe8fb19SBen Gras.Fn kill
472fe8fb19SBen Grasfunction sends the signal given by
482fe8fb19SBen Gras.Fa sig
492fe8fb19SBen Grasto
502fe8fb19SBen Gras.Fa pid ,
512fe8fb19SBen Grasa
522fe8fb19SBen Grasprocess or a group of processes.
532fe8fb19SBen Gras.Fa sig
542fe8fb19SBen Grasmay be one of the signals specified in
552fe8fb19SBen Gras.Xr sigaction 2
562fe8fb19SBen Grasor it may be 0, in which case
572fe8fb19SBen Graserror checking is performed but no
582fe8fb19SBen Grassignal is actually sent.
592fe8fb19SBen GrasThis can be used to check the validity of
602fe8fb19SBen Gras.Fa pid .
612fe8fb19SBen Gras.Pp
622fe8fb19SBen GrasFor a process to have permission to send a signal to a process designated
632fe8fb19SBen Grasby
642fe8fb19SBen Gras.Fa pid ,
652fe8fb19SBen Grasthe real or effective user ID of the receiving process must match
662fe8fb19SBen Grasthat of the sending process or the user must have appropriate privileges
672fe8fb19SBen Gras(such as given by a set-user-ID program or the user is the super-user).
682fe8fb19SBen GrasA single exception is the signal SIGCONT, which may always be sent
692fe8fb19SBen Grasto any descendant of the current process.
702fe8fb19SBen Gras.Bl -tag -width Ds
712fe8fb19SBen Gras.It \&If Fa pid No \&is greater than zero :
722fe8fb19SBen Gras.Fa sig
732fe8fb19SBen Grasis sent to the process whose ID is equal to
742fe8fb19SBen Gras.Fa pid .
752fe8fb19SBen Gras.It \&If Fa pid No \&is zero :
762fe8fb19SBen Gras.Fa sig
772fe8fb19SBen Grasis sent to all processes whose process group ID is equal
782fe8fb19SBen Grasto the process group ID of the sender, and for which the
792fe8fb19SBen Grasprocess has permission;
802fe8fb19SBen Grasthis is a variant of
812fe8fb19SBen Gras.Xr killpg 3 .
822fe8fb19SBen Gras.It \&If Fa pid No \&is \-1 :
832fe8fb19SBen GrasIf the user has super-user privileges,
842fe8fb19SBen Grasthe signal is sent to all processes excluding
852fe8fb19SBen Grassystem processes and the process sending the signal.
862fe8fb19SBen GrasIf the user is not the super user, the signal is sent to all processes
872fe8fb19SBen Graswith the same uid as the user excluding the process sending the signal.
882fe8fb19SBen GrasNo error is returned if any process could be signaled.
892fe8fb19SBen Gras.El
902fe8fb19SBen Gras.Pp
912fe8fb19SBen GrasFor compatibility with System V,
922fe8fb19SBen Grasif the process number is negative but not \-1,
932fe8fb19SBen Grasthe signal is sent to all processes whose process group ID
942fe8fb19SBen Grasis equal to the absolute value of the process number.
952fe8fb19SBen GrasThis is a variant of
962fe8fb19SBen Gras.Xr killpg 3 .
97*0a6a1f1dSLionel Sambuc.Pp
98*0a6a1f1dSLionel SambucIf
99*0a6a1f1dSLionel Sambuc.Fa sig
100*0a6a1f1dSLionel Sambucis equal to
101*0a6a1f1dSLionel Sambuc.Dv 0 ,
102*0a6a1f1dSLionel Sambucthen no signal is sent to the process ID or process group ID, but error
103*0a6a1f1dSLionel Sambucchecking is performed.
104*0a6a1f1dSLionel SambucThis can be used to check if the process ID or process group ID exist.
1052fe8fb19SBen Gras.Sh RETURN VALUES
1062fe8fb19SBen GrasUpon successful completion, a value of 0 is returned.
1072fe8fb19SBen GrasOtherwise, a value of \-1 is returned and
1082fe8fb19SBen Gras.Va errno
1092fe8fb19SBen Grasis set to indicate the error.
1102fe8fb19SBen Gras.Sh ERRORS
1112fe8fb19SBen Gras.Fn kill
1122fe8fb19SBen Graswill fail and no signal will be sent if:
1132fe8fb19SBen Gras.Bl -tag -width Er
1142fe8fb19SBen Gras.It Bq Er EINVAL
1152fe8fb19SBen Gras.Fa sig
1162fe8fb19SBen Grasis not a valid signal number.
1172fe8fb19SBen Gras.It Bq Er EPERM
1182fe8fb19SBen GrasThe sending process is not the super-user and its effective
1192fe8fb19SBen Grasuser id does not match the effective user-id of the receiving process.
1202fe8fb19SBen GrasWhen signaling a process group, this error is returned if any members
1212fe8fb19SBen Grasof the group could not be signaled.
122*0a6a1f1dSLionel Sambuc.It Bq Er ESRCH
123*0a6a1f1dSLionel SambucNo process can be found corresponding to that specified by
124*0a6a1f1dSLionel Sambuc.Fa pid ;
125*0a6a1f1dSLionel Sambucor the process id was given as 0
126*0a6a1f1dSLionel Sambucbut the sending process does not have a process group.
1272fe8fb19SBen Gras.El
1282fe8fb19SBen Gras.Sh SEE ALSO
1292fe8fb19SBen Gras.Xr getpgrp 2 ,
1302fe8fb19SBen Gras.Xr getpid 2 ,
1312fe8fb19SBen Gras.Xr sigaction 2 ,
1322fe8fb19SBen Gras.Xr killpg 3 ,
1332fe8fb19SBen Gras.Xr signal 7
1342fe8fb19SBen Gras.Sh STANDARDS
1352fe8fb19SBen GrasThe
1362fe8fb19SBen Gras.Fn kill
1372fe8fb19SBen Grasfunction is expected to conform to
1382fe8fb19SBen Gras.St -p1003.1-90 .
139