+

Python | os.getpgrp () method

All functions in the os module raise OSError for invalid or unreachable file names and paths or other arguments that are of the correct type but are not accepted by the operating system.

B On UNIX-like operating systems, a process group refers to a collection of one or more processes. It is used to control signal distribution, that is, when a signal is routed to a process group, each member of the process group receives a signal. Each process group is uniquely identified using a process group ID. 
os.getpgrp() in Python is used to get the current process group ID.

Note: os.getsid() is only available on UNIX platforms.

Syntax: os.getpgrp ()

Parameter: No parameter is required

Return Type: This method returns an integer value which denotes the process group id of the current process.

Code: using the os.getpgrp () method

# Python program to explain the os.getpgrp () method

 
# import of the os module

import os

  
# Get the process group ID
# of the current process
# using the os.getpgrp ( )

id = os.getpgrp ( )

 
# Print process group ID
# of the current process

print ( "Process group id of the current process:" , id )

Output:

Get Solution for free from DataCamp guru