


KILL(2V)                  SYSTEM CALLS                   KILL(2V)



NAME
     kill - send a signal to a process or a group of processes

SYNOPSIS
     #include <signal.h>

     int kill(pid, sig)
     int pid;
     int sig;

SYSTEM V SYNOPSIS
     #include <signal.h>

     int kill(pid, sig)
     pid_t pid;
     int sig;

DESCRIPTION
     kill() sends the signal _s_i_g to  a  process  or  a  group  of
     processes.   The  process or group of processes to which the
     signal is to be sent is specified by _p_i_d.  _s_i_g may be one of
     the signals specified in sigvec(2), or it may be 0, in which
     case error checking is performed but no signal  is  actually
     sent.   This can be used to check the validity of _p_i_d or the
     existence of process _p_i_d.

     The real or effective user ID of the  sending  process  must
     match  the  real  or saved set-user ID of the receiving pro-
     cess, unless the effective user ID of the sending process is
     super-user.  A single exception is the signal SIGCONT, which
     may always be sent to any member of the same session as  the
     current process.

     In  the  following  discussion,  ``system  processes''   are
     processes, such as processes 0 and 2, that are not running a
     regular user program.

     If _p_i_d is greater than zero, the signal is sent to the  pro-
     cess whose process ID is equal to _p_i_d.  _p_i_d may equal 1.

     If _p_i_d is 0, the signal is sent  to  all  processes,  except
     system  processes  and  process 1, whose process group ID is
     equal to the process group ID of the sender; this is a vari-
     ant of killpg(2).

     If _p_i_d is -1 and the effective user ID of the sender is  not
     super-user, the signal is sent to all processes, except sys-
     tem processes, process 1, and the process sending  the  sig-
     nal,  whose  real  or  saved set-user ID matches the real or
     effective ID of the sender.





Sun Release 4.1   Last change: 21 January 1990                  1






KILL(2V)                  SYSTEM CALLS                   KILL(2V)



     If _p_i_d is -1 and the effective user  ID  of  the  sender  is
     super-user,  the signal is sent to all processes except sys-
     tem processes, process 1, and the process sending  the  sig-
     nal.

     If _p_i_d is negative but not -1, the signal  is  sent  to  all
     processes,  except system processes, process 1, and the pro-
     cess sending the signal, whose process group ID is equal  to
     the absolute value of _p_i_d; this is a variant of killpg(2).

     Processes may send signals to themselves.

SYSTEM V DESCRIPTION
     If a signal is sent to a group of processes (as with, if _p_i_d
     is  0 or negative), and if the process sending the signal is
     a member of that group, the signal is sent to  that  process
     as well.

     The signal SIGKILL cannot be sent to process 1.

RETURN VALUES
     kill() returns:

     0    on success.

     -1   on failure and sets errno to indicate the error.

ERRORS
     kill() will fail and no signal will be sent if  any  of  the
     following occur:

     EINVAL         _s_i_g was not a valid signal number.

     EPERM          The effective user ID of the sending  process
                    was  not super-user, and neither its real nor
                    effective user ID matched the real  or  saved
                    set-user ID of the receiving process.

     ESRCH          No process could be  found  corresponding  to
                    that specified by _p_i_d.

SYSTEM V ERRORS
     kill() will also fail, and no signal will be  sent,  if  the
     following occurs:

     EINVAL         _s_i_g is SIGKILL and _p_i_d is 1.

SEE ALSO
     getpid(2V), killpg(2), getpgrp(2V), sigvec(2), termio(4)






Sun Release 4.1   Last change: 21 January 1990                  2



