| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- send a signal to a process or a group of processes
#include <sys/types.h>#include <signal.h>intkill(pid_tpid,intsig);
Thekill() function sends a signal to a process or a groupof processes. The process or group of processes to which the signalis to be sent is specified bypid. The signal that isto be sent is specified bysig and is either one from thelist given insignal (seesignal.h(3HEAD)), or 0. Ifsig is 0 (thenull signal), error checking is performed but no signal is actually sent.This can be used to check the validity ofpid.
The real or effective user ID of the sending process must matchthe real or saved (from one of functions in theexec(2) family)user ID of the receiving process, unless the privilege {PRIV_PROC_OWNER} is assertedin the effective set of the sending process (seeIntro(2)), orsigisSIGCONT and the sending process has the same session ID as thereceiving process. A process needs the basic privilege {PRIV_PROC_SESSION} to send signalsto a process with a different session ID. Seeprivileges(5).
Ifpid is greater than 0,sig will be sent to theprocess whose process ID is equal topid.
Ifpid is negative but not(pid_t)-1,sig will be sent toall processes whose process group ID is equal to the absolute valueofpid and for which the process has permission to send asignal.
Ifpid is 0,sig will be sent to all processes excludingspecial processes (seeIntro(2)) whose process group ID is equal to theprocess group ID of the sender.
Ifpid is(pid_t)-1 and the {PRIV_PROC_OWNER} privilege is not asserted inthe effective set of the sending process,sig will be sent toall processes excluding special processes whose real user ID is equal to theeffective user ID of the sender.
Ifpid is(pid_t)-1 and the {PRIV_PROC_OWNER} privilege is asserted in theeffective set of the sending process,sig will be sent to allprocesses excluding special processes.
Upon successful completion, 0 is returned. Otherwise, -1 is returned, no signalis sent, anderrno is set to indicate the error.
Thekill() function will fail if:
Thesig argument is not a valid signal number.
Thesig argument isSIGKILL and thepid argument is(pid_t)-1 (that is, the calling process does not have permission to send the signal to any of the processes specified bypid).
The effective user of the calling process does not match the real or saved user and the calling process does not have the {PRIV_PROC_OWNER} privilege asserted in the effective set, and the calling process either is not sendingSIGCONT to a process that shares the same session ID or does not have the {PRIV_PROC_SESSION} privilege asserted and is trying to send a signal to a process with a different session ID.
No process or process group can be found corresponding to that specified bypid.
Thesigsend(2) function provides a more versatile way to send signals toprocesses.
Seeattributes(5) for descriptions of the following attributes:
|
kill(1),Intro(2),exec(2),getpid(2),getsid(2),setpgrp(2),sigaction(2),sigsend(2),signal(3C),signal.h(3HEAD),attributes(5),privileges(5),standards(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |