process_group


Processes can be conveniently grouped together using a process group. Each process group has a unique numeric identifier. Each process belongs to a single process group, and a child inherits its parent's process group.

One process in each process group is called the group leader. In most cases, all additional processes in a process group are descendants of the process group leader. The process ID and process group ID are the same value for the group leader process.

You can send a signal to every process in a process group using the signal() function defined in os_process_group . Similarly, the current process can wait for any child in a particular process group using os_this_process::wait_for_any_child_in() .

When sending signals to process groups, permissions affect whether the signal is actually received. For the signal to be received, the caller's user ID or the effective user ID must match the effective or saved user ID of the receiving process. The single exception to this rule is resume() , which can always be sent to all members of the calling process' session.

If the caller has an effective user ID of superuser, all processes in the process group receive the signal.

Conversions permit interchangeable use of os_process_group and os_pid_t to.

Library

Platform<ToolKit> for UNIX

Declaration

#include <ospace/unix/procgrp.h>

class os_process_group

Interface

Constructor
os_process_group( os_pid_t pgid )
Constructs an object to represent the process group with process group ID pgid (default OS_UNDEFINED ).
Constructor
os_process_group( const os_process_group& process_group )
Constructs an object that is a copy of process_group .
<
bool operator<( const os_process_group& process_group ) const
Returns true if the process group ID is less than process_group .
=
os_process_group& operator=( os_pid_t process_group )
Assigns an object from process_group .
=
os_process_group& operator=( const os_process_group& process_group )
Assigns an object from process_group .
==
bool operator==( const os_process_group& process_group ) const
Returns true if the process group ID is the same as process_group .
(os_pid_t)
operator os_pid_t() const
Returns the process group ID.
defined
bool defined() const
Returns true if the process group ID is not OS_UNDEFINED .
hangup
void hangup()
Sends a hangup signal to all processes in the group.

Throws: os_unix_toolkit_error

interrupt
void interrupt()
Sends an interrupt signal to all processes in the group.

Throws: os_unix_toolkit_error

keyboard_suspend
void keyboard_suspend()
Sends a stop signal like that generated by a keyboard action to all processes in the group.

Throws: os_unix_toolkit_error

kill
void kill()
Send a kill signal to all processes in the group.

Throws: os_unix_toolkit_error

pgid
void pgid( os_pid_t pgid )
Sets the process group ID to pgid .
pgid
os_pid_t pgid() const
Returns the process group ID.
print
void print( ostream& stream ) const
Prints process group ID to stream .
priority
int priority() const
Returns the lowest nice value associated with any of the processes. Nice values are a measure of execution priority. The range varies slightly between platforms, but is usually -20 (highest priority) to 20 (lowest priority).

Throws: os_unix_toolkit_error

priority
void priority( int value )
Sets the execution priority (nice) value of all processes in the group to value . The range varies between platforms, but is usually -20 (highest priority) to 20 (lowest priority). Only a process group with superuser privileges can lower a priority.

Throws: os_unix_toolkit_error

quit
void quit()
Sends a quit signal to all of the processes in the group.

Throws: os_unix_toolkit_error

resume
void resume()
Sends a continue signal to all processes in the group. This signal resumes execution of all stopped processes. When sending a continue signal, all processes, regardless of their effective and saved user IDs, receive the signal. Note that this signal is the exception to normal permissions involving sending signals to process groups.

Throws: os_unix_toolkit_error

signal
void signal( os_sig_t code )
Sends the signal with code code to all of the processes in the group.

Throws: os_unix_toolkit_error

suspend
void suspend()
Sends a stop signal to all processes in the group, suspending their execution. This signal is only valid for systems that support job control.

Throws: os_unix_toolkit_error

terminate
void terminate()
Sends a terminate signal to all processes in the group. This is the signal sent by default when the kill(1) UNIX command is executed.

Throws: os_unix_toolkit_error

valid
bool valid() const
Returns true if this process is a valid, registered, UNIX process.

Non-Member Functions

<<
ostream& operator<<( ostream& stream , const os_process_group& process_group )
Prints process_group to stream .

Universal Streaming Service

#include <ospace/uss/unix.h>
<<
os_bstream& operator<<( os_bstream& stream , const os_process_group& process_group )
Writes process_group to stream .
>>
os_bstream& operator>>( os_bstream& stream , os_process_group& process_group )
Reads process_group from stream .

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only. - For use by licensed users only.