KILL(2,L) AIX Technical Reference KILL(2,L)
-------------------------------------------------------------------------------
kill, kill3, killpg
PURPOSE
Sends a signal to a process or to a group of processes.
LIBRARY
Standard C Library (libc.a)
SYNTAX
int kill (pid, sig)
pid_t pid;
int sig;
int kill3 (pid, sig, arg)
pid_t pid;
int sig, arg;
DESCRIPTION
The kill system call sends the signal specified by the sig parameter to the
process or group of processes specified by the pid parameter. (For information
on valid signals, see "sigaction, sigvec, signal.") If the sig parameter is 0
(the null signal), error checking is performed but no signal is sent. This can
be used to check the validity of pid.
To send a signal to another process, at least one of the following must be
true:
o Either the real or the effective user ID of the sending process matches the
real user ID or the saved set-user-ID of the receiving process.
o The effective user ID of the sending process is superuser.
Note: An exception to the above is the signal SIGCONT, which also may be sent
to any process which is a descendant of the sending process. This
allows a command interpreter such as csh to restart processes stopped by
a stop signal sent from the keyboard, when those processes may have
different real and effective user IDs.
The processes that have the process IDs 0 and 1 are special processes and are
sometimes referred to here as proc0 and proc1, respectively.
If the pid parameter is greater than 0, the signal specified by the sig
parameter is sent to the process whose process ID is equal to the value of the
pid parameter.
Processed November 7, 1990 KILL(2,L) 1
KILL(2,L) AIX Technical Reference KILL(2,L)
If the pid parameter is equal to 0, the signal specified by the sig parameter
is sent to all of the processes, excluding proc0 and proc1, whose process group
ID is equal to the process group ID of the sender.
If the pid parameter is equal to -1, the signal specified by the sig parameter
is sent to all of the processes, excluding system processes.
If the pid parameter is negative but not -1, the signal specified by the sig
parameter is sent to all of the processes whose process group ID is equal to
the absolute value of the pid parameter.
If the Transparent Computing Facility is installed, kill3 may be used to send
additional information with a signal. Currently, kill3 is only viable with
SIGMIGRATE, in which case the arg parameter is the number of the site to which
the processes receiving the signal will migrate. The user signal-catching
routines do not receive the third argument of a kill3 for signals other than
SIGMIGRATE. If arg is 0, the processes will migrate to the sender's site.
Note that SIGMIGRATE is only a request to migrate. If the receiving process is
ignoring or catching SIGMIGRATE, or if the migration fails, the kill call
succeeds but the signal does not cause the process to move. The receiving
process also may not migrate immediately if it is stopped or if it is waiting
for a file lock. In any case, the kill call usually returns before any
migration has completed. The actual site on which a process is executing may
be determined by using the site system call.
COMPATIBILITY INTERFACES
The following additional interface is provided in Berkeley Compatibility
Library (libbsd.a):
killpg (pgrp, sig)
int pgrp;
int sig;
is equivalent to:
if (pgrp < 0)
{
errno = ESRCH;
return (-1);
}
return (kill (-pgrp, sig));
RETURN VALUE
Upon successful completion, kill returns a value of 0. If kill fails, a value
of -1 is returned and errno is set to indicate the error.
ERROR CONDITIONS
The kill system call fails and no signal is sent if one or more of the
following are true:
Processed November 7, 1990 KILL(2,L) 2
KILL(2,L) AIX Technical Reference KILL(2,L)
EINVAL sig is not a valid signal number.
EINVAL sig is SIGKILL and pid is 1 (proc1).
ESRCH No process can be found corresponding to that specified by pid.
EPERM The user ID of the sending process is not superuser, and the real or
effective user ID does not match the real or saved set-user-ID of the
receiving process.
If the Transparent Computing Facility is installed on your system, kill3 can
also fail if the following is true:
EPERM The user ID of the sending process is not superuser, sig is SIGMIGRATE,
and the sending process does not have permission to execute on the
specified site (see "getxperm, setxperm").
RELATED INFORMATION
In this book: "exec: execl, execv, execle, execve, execlp, execvp," "getpid,
getpgrp, getppid," "getxperm, setxperm," "migrate," "setpgid, setpgrp, setsid,"
and "sigaction, sigvec, signal."
The csh, kill, and sh commands in AIX Operating System Commands Reference.
Processed November 7, 1990 KILL(2,L) 3