kill(2) CLIX kill(2)
NAME
kill - Sends a signal to a process or to a group of processes
LIBRARY
Standard I/O Library (libc.a)
SYNOPSIS
int kill(
pid_t process ,
int signal );
PARAMETERS
process Specifies the process or group of processes. 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 process parameter has a value greater than 0, the signal
specified by the signal parameter is sent to the process that
has a process ID equal to the value of the process parameter.
The process parameter may equal 1.
If the process parameter is equal to 0, the signal specified by
the signal parameter is sent to all of the processes, excluding
proc0 and proc1, for which the process group ID is equal to the
process group ID of the sender.
If the process parameter is equal to -1 and the effective user
ID of the sender is not superuser, the signal specified by the
signal parameter is sent to all processes for which the real
user ID is equal to the effective user ID of the sender,
excluding proc0 and proc1.
If the process parameter is equal to -1 and the effective user
ID of the sender is superuser, the signal specified by the
signal parameter is sent to all of the processes, excluding
proc0 and proc1.
If the process parameter is negative but not -1, the signal
specified by the signal parameter is sent to all processes that
have a process group ID equal to the absolute value of the
process parameter.
signal Specifies the signal and is either a value from the list given
in the signal() function, or 0. If the signal parameter is 0
(the null signal), error checking is performed but no signal is
sent. This can be used to check the validity of the process
parameter.
2/94 - Intergraph Corporation 1
kill(2) CLIX kill(2)
DESCRIPTION
The kill() function sends the signal specified by the signal parameter to
the process or group of processes specified by the process parameter.
To send a signal to another process, either the real or the effective user
ID of the sending process must match the real or effective user ID of the
receiving process, unless the effective user ID of the sending process is
superuser.
EXAMPLES
1. To send a SIGUSR1 to a given process:
if (kill(pid, SIGUSR1) == -1)
perror("Could not kill process");
2. To send a SIGKILL to all processes in a given process group:
if (kill(-pgrp, SIGKILL) == -1)
perror("Could not kill process group");
RETURN VALUES
Upon successful completion, kill() returns a value of 0. Otherwise, a
value of -1 is returned and the global variable errno is set to indicate
the error.
ERRORS
The kill() function fails and no signal is sent if one or more of the
following are true:
[EINVAL] The signal parameter is not a valid signal number.
[EINVAL] The signal parameter is SIGKILL and the process parameter is 1
(proc1).
[ESRCH] No process can be found corresponding to that specified by the
process parameter.
[EPERM] The real or effective user ID of the sending process does not
match the real or effective user ID of the receiving process,
or the user ID of the sending process is not superuser.
RELATED INFORMATION
Commands: kill(1)
2 Intergraph Corporation - 2/94
kill(2) CLIX kill(2)
Functions: getpid(2), killpg(2), raise(2), setpgrp(2), sigaction(2),
signal(2), sigset(2)
2/94 - Intergraph Corporation 3