xref: /csrg-svn/lib/libc/sys/kill.2 (revision 66931)
161181Sbostic.\" Copyright (c) 1980, 1991, 1993
261181Sbostic.\"	The Regents of the University of California.  All rights reserved.
320032Smckusick.\"
447208Scael.\" %sccs.include.redist.man%
520032Smckusick.\"
6*66931Sbostic.\"     @(#)kill.2	8.3 (Berkeley) 04/19/94
747208Scael.\"
847208Scael.Dd
947208Scael.Dt KILL 2
1047208Scael.Os BSD 4
1147208Scael.Sh NAME
1247208Scael.Nm kill
1347208Scael.Nd send signal to a process
1447208Scael.Sh SYNOPSIS
1555759Sbostic.Fd #include <signal.h>
1647208Scael.Ft int
1747208Scael.Fn kill "pid_t pid" "int sig"
1847208Scael.Sh DESCRIPTION
1947208ScaelThe
2047208Scael.Fn kill
2147208Scaelfunction sends the signal given by
2247208Scael.Fa sig
2347208Scaelto
2447208Scael.Fa pid ,
2547208Scaela
2647208Scaelprocess or a group of processes.
2747208Scael.Fa Sig
2820033Smckusickmay be one of the signals specified in
2947208Scael.Xr sigaction 2
3020033Smckusickor it may be 0, in which case
3120033Smckusickerror checking is performed but no
3220033Smckusicksignal is actually sent.
3320033SmckusickThis can be used to check the validity of
3447208Scael.Fa pid .
3547208Scael.Pp
3647208ScaelFor a process to have permission to send a signal to a process designated
3747208Scaelby
3847208Scael.Fa pid ,
39*66931Sbosticthe real or effective user ID of the receiving process must match
4047208Scaelthat of the sending process or the user must have appropriate privileges
4147208Scael(such as given by a set-user-ID program or the user is the super-user).
4223811SsechrestA single exception is the signal SIGCONT, which may always be sent
4328107Skarelsto any descendant of the current process.
4447208Scael.Bl -tag -width Ds
4547208Scael.It \&If Fa pid No \&is greater than zero :
4647208Scael.Fa Sig
4747208Scaelis sent to the process whose ID is equal to
4847208Scael.Fa pid.
4947208Scael.It \&If Fa pid No \&is zero :
5047208Scael.Fa Sig
5147208Scaelis sent to all processes whose group ID is equal
5247208Scaelto the process group ID of the sender, and for which the
5347208Scaelprocess has permission;
5447208Scaelthis is a variant of
5547208Scael.Xr killpg 2 .
5647208Scael.It \&If Fa pid No \&is -1 :
5765100SmckusickIf the user has super-user privileges,
5847208Scaelthe signal is sent to all processes excluding
5951352Sbosticsystem processes and the process sending the signal.
6051352SbosticIf the user is not the super user, the signal is sent to all processes
6151352Sbosticwith the same uid as the user excluding the process sending the signal.
6228107SkarelsNo error is returned if any process could be signaled.
6347208Scael.El
6447208Scael.Pp
6520999SmckusickFor compatibility with System V,
6647208Scaelif the process number is negative but not -1,
6727199Slepreauthe signal is sent to all processes whose process group ID
6820999Smckusickis equal to the absolute value of the process number.
6920999SmckusickThis is a variant of
7047208Scael.Xr killpg 2 .
7147208Scael.Sh RETURN VALUES
7220033SmckusickUpon successful completion, a value of 0 is returned.
7347208ScaelOtherwise, a value of -1 is returned and
7447208Scael.Va errno
7520033Smckusickis set to indicate the error.
7647208Scael.Sh ERRORS
7747208Scael.Fn Kill
7847208Scaelwill fail and no signal will be sent if:
7947208Scael.Bl -tag -width [EINVAL]
8047208Scael.It Bq Er EINVAL
8147208Scael.Fa Sig
8247208Scaelis not a valid signal number.
8347208Scael.It Bq Er ESRCH
8447208ScaelNo process can be found corresponding to that specified by
8547208Scael.Fa pid .
8647208Scael.It Bq Er ESRCH
8728107SkarelsThe process id was given as 0
8828107Skarelsbut the sending process does not have a process group.
8947208Scael.It Bq Er EPERM
9020033SmckusickThe sending process is not the super-user and its effective
9120033Smckusickuser id does not match the effective user-id of the receiving process.
9247208ScaelWhen signaling a process group, this error is returned if any members
9328107Skarelsof the group could not be signaled.
9447208Scael.El
9547208Scael.Sh SEE ALSO
9647208Scael.Xr getpid 2 ,
9747208Scael.Xr getpgrp 2 ,
9847208Scael.Xr killpg 2 ,
9947208Scael.Xr sigaction 2
10047208Scael.Sh STANDARDS
10147208ScaelThe
10247208Scael.Fn kill
10347208Scaelfunction is expected to
10447208Scaelconform to IEEE Std 1003.1-1988
10547208Scael.Pq Dq Tn POSIX .
106