in a Linux system, each process belongs to a process group, and each process group has a process group ID (pgid), and the value of the process group ID equals the process ID of the leader process. The first program that is typically executed under the shell becomes a leader process, and all subsequent processes that are related to this process are part of this process group (unless the child process uses the Setpgid function to change its own process group ID). =======================================================The Linux system provides the GETPGRP function and the Getpgid function to read the process group IDs of the processes, providing the Setpgid function to set the process group ID of the process. function Prototypes:function Parameters:
- The GETPGRP function has no arguments and can only be used to read the process group ID that the calling process belongs to
- The Getpgid function is used to read the process group ID of the process ID PID, which, when pid=0, is equivalent to the GETPGRP function
- The Setpgid function is used to set the process ID of the process to PID for the process group ID of Pgid. If pid=0, it is equivalent to setting the process group ID of the calling process itself, or, if pgid=0, the same set process group ID and PID. Note that a process can only set a new process group ID for the process itself or its child processes, and that the new process group and the original process group must belong to the same session
return Value:
- GETPGRP: Always called successfully, returns the process group ID of the calling process
- Getpgid: Call failed to return the process group ID of the PID successfully returned-1
- Setpgid: return 0 on successful call, return 1 if call fails
Process Control (14)---process group