killpg
Purpose
Sends a signal to a process group.
Library
Berkeley Library (libbsd.a)
Syntax
int killpg (pgrp, sig)
int pgrp, sig;
Description
The killpg subroutine sends the signal specified by the
sig parameter to the process group in the pgrp parameter.
If the sending process does not have an effective user ID
of superuser, the sending process and the process group
members must have the same user ID or the call fails.
The killpg subroutine is implemented with
kill(-(pgrp), sig);, so it cannot be used to signal all
descendants of the init process. For example, a call to
killpg similar to the following:
killpg(1, SIGXXX)
does, however, result in all processes in process group 1
except init receiving the signal.
Return Value
When the call succeeds, a value of 0 is returned. If the
killpg subroutine fails, a value of -1 is returned and
errno is set to indicate the error.
Diagnostics
The killpg subroutine fails and no signal is sent if one
or more of the following is true:
EINVAL The sig parameter is not a valid signal.
ESRCH No process exists in the process group speci-
fied by pgrp.
ESRCH The pgrp parameter is 0, but the sending
process does not have a process group.
EPERM The sending process does not have an effective
user ID of superuser, and the sender and at
least one target process have different effec-
tive user IDs.
Related Information
In this book: "getpid, getpgrp, getppid," "kill," and
"sigvec."