os.getresgid() method –
Syntax: os.getresgid()
Parameter: No parameter is required
Return Type: This method returns a tuple whose attributes denotes real, effective, and saved group ids of the current process.
# Python program to explain os.getresgid() method # importing os module import os # Get the current process’s # real, effective, and saved group ids. # using os.getresgid() method rgid, egid, sgid = os.getresgid() # Print the current process’s # real, effective, and saved group ids. print ( "Real group id of the current process:" , rgid) print ( "Effective group id of the current process:" , egid) print ( "Saved group id of the current process:" , sgid) |
Output:
Python | os.getresgid() and os.setresgid() method
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
All functions in os module raise OSError in the case of invalid or inaccessible file names and paths, or other arguments that have the correct type, but are not accepted by the operating system.
os.getresgid()
method in Python is used to get the current process’s real, effective, and saved group ids and os.setresgid()
method is used to set the current process’s real, effective, and saved group ids.
Alternatively, we can also get real and effective group ids of the current process using os.getgid()
and os.getegid()
method respectively and can also set the real and effective group ids of the current process using os.setgid()
and os.setegid()
method respectively.
Note: os.setresgid()
and os.getresgid()
methods are only available on UNIX platforms and functionality of os.setresgid()
method is typically available only to the superuser as only superuser can change group IDs of a process. Superuser means a root user or an administrative user who has all the permissions to run or execute any program in the operating system.