Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
#define _XOPEN_SOURCE_EXTENDED 1
#include <unistd.h>
int setregid(gid_t rgid, gid_t egid);
The setregid() function sets the real and/or effective GIDs for the calling process to the values specified by the input real and effective GID values. If a specified value is equal to -1, the corresponding real or effective GID of the calling process is left unchanged.
A process with appropriate privileges can set the real and effective GID to any valid GID value. An unprivileged process can only set the effective GID if the EGID argument is equal to either the real, effective, or saved GID of the process. An unprivileged process can only set the real GID if the RGID argument is equal to either the real, effective, or saved GID of the process.
If the setregid() function is issued from multiple tasks within one address space, use synchronization to ensure that the setregid() functions are not performed concurrently. The execution of setregid() function concurrently within one address space can yield unpredictable results.
The setregid() function does not change any supplementary GIDs of the calling process.
If successful, setregid() returns 0.