PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
Process groups

Process groups. More...

Collaboration diagram for Process groups:

Detailed Description

Process groups.

Process groups allow related processes to be grouped together, enabling operations such as sending notes to all processes within a group.

As an example, if a user wishes to terminate a shell they most likely additionally want to terminate all child processes started by that shell. By placing all such processes in the same group, a single "terminate" note can be sent to the entire group, effectively terminating all related processes.

Data Structures

struct  group_entry_t
 Group entry structure. More...
 
struct  group_t
 Process group structure. More...
 

Functions

void group_entry_init (group_entry_t *entry)
 Initializes a group entry.
 
void group_entry_deinit (group_entry_t *entry)
 Deinitializes a group entry.
 
uint64_t group_add (gid_t gid, group_entry_t *entry)
 Adds a process to a group.
 
void group_remove (group_entry_t *entry)
 Removes a process from its group.
 
gid_t group_get_id (group_entry_t *entry)
 Gets the ID of the group of the specified entry.
 
uint64_t group_send_note (group_entry_t *entry, const char *note)
 Sends a note to all processes in the group of the specified entry.
 

Function Documentation

◆ group_entry_init()

void group_entry_init ( group_entry_t entry)

Initializes a group entry.

Parameters
entryThe group entry to initialize.

Definition at line 14 of file group.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ group_entry_deinit()

void group_entry_deinit ( group_entry_t entry)

Deinitializes a group entry.

Parameters
entryThe group entry to deinitialize.

Definition at line 20 of file group.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ group_add()

uint64_t group_add ( gid_t  gid,
group_entry_t entry 
)

Adds a process to a group.

Parameters
gidThe group ID to add the process to, or GID_NONE to create a new group.
entryThe group entry of the process to add to the group.
Returns
On success, 0. On failure, ERR and errno is set to:
  • EINVAL: Invalid parameters.
  • ENOENT: The specified group does not exist.
  • EBUSY: The entry is already part of a group.
  • ENOMEM: Out of memory.

Definition at line 25 of file group.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ group_remove()

void group_remove ( group_entry_t entry)

Removes a process from its group.

If the group becomes empty after removing the process, it will be freed.

Parameters
entryThe group entry of the process to remove from its group, or NULL for no-op.

Definition at line 73 of file group.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ group_get_id()

gid_t group_get_id ( group_entry_t entry)

Gets the ID of the group of the specified entry.

Parameters
entryThe group entry to get the group ID from.
Returns
The group ID or GID_NONE if the entry is not part of a group.

Definition at line 98 of file group.c.

Here is the caller graph for this function:

◆ group_send_note()

uint64_t group_send_note ( group_entry_t entry,
const char *  note 
)

Sends a note to all processes in the group of the specified entry.

Parameters
entryThe entry within the group to send the note to.
noteThe note string to send.
Returns
On success, 0. On failure, ERR and errno is set to:

Definition at line 115 of file group.c.

Here is the call graph for this function:
Here is the caller graph for this function: