PatchworkOS  dbbdc99
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 of that shell. By placing all such processes in the same group, a single "terminate" note can be sent to the entire group.

Data Structures

struct  group_member_t
 Group member structure. More...
 
struct  group_t
 Process group structure. More...
 

Functions

uint64_t group_member_init (group_member_t *member, group_member_t *group)
 Initializes a group member.
 
void group_member_deinit (group_member_t *member)
 Deinitializes a group member.
 
group_tgroup_get (group_member_t *member)
 Retrieve the group of a group member.
 
void group_add (group_t *group, group_member_t *member)
 Joins a process to a specific group.
 
void group_remove (group_member_t *member)
 Removes a process from its group.
 
uint64_t group_send_note (group_member_t *member, const char *note)
 Sends a note to all processes in the group of the specified member.
 

Function Documentation

◆ group_member_init()

uint64_t group_member_init ( group_member_t member,
group_member_t group 
)

Initializes a group member.

Parameters
memberThe group member to initialize.
groupA member storing the group to add the new member to, or NULL to create a new group.
Returns
On success, 0. On failure, ERR and errno is set to:

Definition at line 42 of file group.c.

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

◆ group_member_deinit()

void group_member_deinit ( group_member_t member)

Deinitializes a group member.

Parameters
memberThe group member to deinitialize.

Definition at line 74 of file group.c.

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

◆ group_get()

group_t * group_get ( group_member_t member)

Retrieve the group of a group member.

It is the responsibility of the caller to use UNREF() or UNREF_DEFER() on the returned group when it is no longer needed.

Parameters
memberThe group member.
Returns
On success, a reference to the group. On failure, NULL and errno is set to:
  • EINVAL: Invalid parameters.
  • ESRCH: The member is not part of any group.

Definition at line 79 of file group.c.

Here is the caller graph for this function:

◆ group_add()

void group_add ( group_t group,
group_member_t member 
)

Joins a process to a specific group.

If the member is already in a group it will be removed from that group first.

Parameters
groupThe group to join.
memberThe group member of the process to add to the group.

Definition at line 98 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_member_t member)

Removes a process from its group.

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

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

Definition at line 120 of file group.c.

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

◆ group_send_note()

uint64_t group_send_note ( group_member_t member,
const char *  note 
)

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

Parameters
memberThe member 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 142 of file group.c.

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