Skip to content



setpgid - set the process group ID for a process.


The setpgid() system call is used to set the process group ID of a specific process.

This is particularly useful for creating or changing sessions, job control, and other process grouping related tasks in Unix-like operating systems. When a new process is created, it inherits the process group ID of its parent. Using setpgid(), processes can be re-assigned to different groups, facilitating group-based operations like signaling.


  • pid:pid_t[K] - Process ID of the target process. If pid is zero, the process ID of the calling process is used.
  • pgid:pid_t[K] - The process group ID to be set. If pgid is zero, the process ID of the process specified by pid is used.

Available Tags

  • K - Originated from kernel-space.
  • U - Originated from user space.
  • TOCTOU - Vulnerable to TOCTOU (time of check, time of use).
  • OPT - Optional argument - might not always be available (passed with null value).




Tracepoint (through sys_enter).


To observe and trace the invocation of the setpgid() system call, capturing information about the process and the new process group ID.

Example Use Case

Monitoring process group changes, especially in scenarios where job control or session management is vital, such as in shell environments or process managers.


Improper usage of setpgid() can lead to processes being unintentionally grouped together, potentially causing unintended signaling or termination of processes.

  • getpgid() - Retrieve the process group ID of a process.
  • setsid() - Create a new session and set the process group ID.
  • getpgrp() - Get the process group ID of the calling process.

This document was automatically generated by OpenAI and reviewed by a Human.