setregid(2)
Name
setregid − set real and effective group ID
Syntax
setregid(rgid, egid)
int rgid, egid;
Description
The real and effective group ID’s of the current process are set to the arguments.
Supplying a value of −1 for either the real or effective group ID forces the system to substitute the current ID for the −1 parameter.
Environment
BSD
If the process is superuser, or rgid and egid matches with the real group ID, the effective group ID, or the saved set-group-id (as described in execve() ), then the real, effective, and saved set-group-id are set to rgid, egid, and egid, respectively.
POSIX
SYSTEM-FIVE
When your program is compiled in POSIX or SYSTEM-FIVE mode, the following semantics apply when using the setregid function.
If the process is the superuser, the real, effective, and saved set-group-id (as described in execve() ) are set to rgid, egid, and egid, respectively.
If the process is not the superuser, but the rgid and egid matches the real group ID, the effective group ID (only in SYSTEM-FIVE and BSD environment), or the saved set-group-id, then the effective ID is set to egid. The real group ID and the saved set-group-id are left unchanged.
Return Value
Upon successful completion, a value of zero (0) is returned. Otherwise, a value of −1 is returned, and errno is set to indicate the error.
Diagnostics
[EPERM] The current process is not the superuser and the egid and rgid specified does not match with the real group ID or the effective group ID (only in SYSTEM-FIVE and BSD environment) or the saved set-group-id.