Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
KILL(2V)							      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	sig 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  pid.   sig  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 pid or the existence of process pid.

       The real	or effective user ID of	the sending  process  must  match  the
       real  or	 saved set-user	ID of the receiving process, unless the	effec-
       tive 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  pid	is  greater than zero, the signal is sent to the process whose
       process ID is equal to pid.  pid	may equal 1.

       If pid is 0, the	signal is sent to all processes,  except  system  pro-
       cesses  and  process  1,	whose process group ID is equal	to the process
       group ID	of the sender; this is a variant of killpg(2).

       If pid is -1 and	the effective user ID of the sender is not super-user,
       the  signal  is sent to all processes, except system processes, process
       1, and the process sending the signal, whose real or saved set-user  ID
       matches the real	or effective ID	of the sender.

       If pid is -1 and	the effective user ID of the sender is super-user, the
       signal is sent to all processes except system processes,	process	1, and
       the process sending the signal.

       If pid is negative but not -1, the signal is sent to all	processes, ex-
       cept system processes, process 1, and the process sending  the  signal,
       whose process group ID is equal to the absolute value of	pid; 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	pid  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 oc-
       cur:

       EINVAL	      sig was not a valid signal number.

       EPERM	      The effective user ID of the sending process was not su-
		      per-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	speci-
		      fied by pid.

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

       EINVAL	      sig is SIGKILL and pid is	1.

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

				21 January 1990			      KILL(2V)

NAME | SYNOPSIS | SYSTEM V SYNOPSIS | DESCRIPTION | SYSTEM V DESCRIPTION | RETURN VALUES | ERRORS | SYSTEM V ERRORS | SEE ALSO

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=kill&sektion=2v&manpath=SunOS+4.1.3>

home | help