[9] | 1 | .\" Copyright (c) 1980 Regents of the University of California.
|
---|
| 2 | .\" All rights reserved. The Berkeley software License Agreement
|
---|
| 3 | .\" specifies the terms and conditions for redistribution.
|
---|
| 4 | .\"
|
---|
| 5 | .\" @(#)kill.2 6.5 (Berkeley) 5/14/86
|
---|
| 6 | .\"
|
---|
| 7 | .TH KILL 2 "May 14, 1986"
|
---|
| 8 | .UC 4
|
---|
| 9 | .SH NAME
|
---|
| 10 | kill \- send signal to a process
|
---|
| 11 | .SH SYNOPSIS
|
---|
| 12 | .nf
|
---|
| 13 | .ft B
|
---|
| 14 | #include <sys/types.h>
|
---|
| 15 | #include <signal.h>
|
---|
| 16 |
|
---|
| 17 | int kill(pid_t \fIpid\fP, int \fIsig\fP)
|
---|
| 18 | .ft R
|
---|
| 19 | .fi
|
---|
| 20 | .SH DESCRIPTION
|
---|
| 21 | .B Kill
|
---|
| 22 | sends the signal \fIsig\fP
|
---|
| 23 | to a process, specified by the process number
|
---|
| 24 | .IR pid .
|
---|
| 25 | .I Sig
|
---|
| 26 | may be one of the signals specified in
|
---|
| 27 | .BR sigaction (2),
|
---|
| 28 | or it may be 0, in which case
|
---|
| 29 | error checking is performed but no
|
---|
| 30 | signal is actually sent.
|
---|
| 31 | This can be used to check the validity of
|
---|
| 32 | .IR pid .
|
---|
| 33 | .PP
|
---|
| 34 | The sending and receiving processes must
|
---|
| 35 | have the same effective user ID, otherwise
|
---|
| 36 | this call is restricted to the super-user.
|
---|
| 37 | .ig
|
---|
| 38 | A single exception is the signal SIGCONT, which may always be sent
|
---|
| 39 | to any descendant of the current process.
|
---|
| 40 | ..
|
---|
| 41 | .PP
|
---|
| 42 | If the process number is 0,
|
---|
| 43 | the signal is sent to all processes in the
|
---|
| 44 | sender's process group.
|
---|
| 45 | .PP
|
---|
| 46 | If the process number is \-1
|
---|
| 47 | and the user is the super-user,
|
---|
| 48 | the signal is broadcast universally
|
---|
| 49 | except to
|
---|
| 50 | .B init
|
---|
| 51 | and the process sending the signal.
|
---|
| 52 | If the process number is \-1
|
---|
| 53 | and the user is not the super-user,
|
---|
| 54 | the signal is broadcast universally to
|
---|
| 55 | all processes with the same uid as the user
|
---|
| 56 | except the process sending the signal.
|
---|
| 57 | No error is returned if any process could be signaled.
|
---|
| 58 | .PP
|
---|
| 59 | If the process number is negative but not \-1,
|
---|
| 60 | the signal is sent to all processes whose process group ID
|
---|
| 61 | is equal to the absolute value of the process number.
|
---|
| 62 | .PP
|
---|
| 63 | Processes may send signals to themselves.
|
---|
| 64 | .SH "RETURN VALUE
|
---|
| 65 | Upon successful completion, a value of 0 is returned.
|
---|
| 66 | Otherwise, a value of \-1 is returned and
|
---|
| 67 | .B errno
|
---|
| 68 | is set to indicate the error.
|
---|
| 69 | .SH "ERRORS
|
---|
| 70 | .B Kill
|
---|
| 71 | will fail and no signal will be sent if any of the following
|
---|
| 72 | occur:
|
---|
| 73 | .TP 15
|
---|
| 74 | [EINVAL]
|
---|
| 75 | \fISig\fP is not a valid signal number.
|
---|
| 76 | .TP 15
|
---|
| 77 | [ESRCH]
|
---|
| 78 | No process can be found corresponding to that specified by \fIpid\fP.
|
---|
| 79 | .TP 15
|
---|
| 80 | [ESRCH]
|
---|
| 81 | The process id was given as 0
|
---|
| 82 | but the sending process does not have a process group.
|
---|
| 83 | .TP 15
|
---|
| 84 | [EPERM]
|
---|
| 85 | The sending process is not the super-user and its effective
|
---|
| 86 | user id does not match the effective user-id of the receiving process.
|
---|
| 87 | When signaling a process group, this error was returned if any members
|
---|
| 88 | of the group could not be signaled.
|
---|
| 89 | .SH "SEE ALSO"
|
---|
| 90 | .BR getpid (2),
|
---|
| 91 | .BR getpgrp (2),
|
---|
| 92 | .BR sigaction (2),
|
---|
| 93 | .BR raise (3).
|
---|