killpg() — Send a signal to a process group
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both | POSIX(ON) |
Format
#define _XOPEN_SOURCE_EXTENDED 1
#include <signal.h>
int killpg(pid_t pgrp, int sig);
General description
The killpg() function sends a signal to a process group.
A process has permission to send a signal if the real or effective user ID of the sender is the same as the real or effective user ID of the intended recipient. A process can also send signals if it has appropriate privileges. If _POSIX_SAVED_IDS is defined in the <unistd.h> include file, the saved set user ID of the intended recipient is checked instead of its effective user ID.
- pid_t pgrp;
- Specifies the process group that the caller wants to send a signal
to:
- If pgrp is greater than one, killpg() sends the signal, sig, to the process whose process group ID is equal to pgrp and which the sender has appropriate privileges to send a signal.
- If pgrp is equal to or less than one, killpg() returns a -1 and sets errno to EINVAL.
- int sig;
- The signal that should be sent to the processes specified by pid. (For a list of signals, see Table 1.) This must be zero, or one of the signals defined in the <signal.h> include file. If sig is zero, killpg() performs error checking but doesn't really send a signal. You can code sig as zero to check whether the pid argument is valid.
This function is supported only in a POSIX program.
Usage notes
The use of the SIGTHSTOP and SIGTHCONT signal is not supported with this function.
Returned value
If successful, killpg() returns 0 if it has permission to send sig to any of the processes in the process group ID specified by pgrp.
- Error Code
- Description
- EINVAL
- The value of sig is incorrect or is not the number of a supported signal, or the value of pgrp is less than or equal to one.
- EPERM
- The caller does not have permission to send the signal to any process in the process group ID specified by pgrp.
- ESRCH
- There are no process groups corresponding to pgrp.
Related information
- signal.h
- bsd_signal() — BSD version of signal()
- getpgid() — Get process group ID
- getpid() — Get the process ID
- kill() — Send a signal to a process
- raise() — Raise signal
- setsid() — Create session, set process group ID
- sigaction() — Examine or change a signal action
- sighold() — Add a signal to a thread
- sigignore() — Set disposition to ignore a signal
- signal() — Handle interrupts
- sigprocmask() — Examine or change a thread
- sigrelse() — Remove a signal from a thread
- sigset() — Change a signal action or a thread