setgid - set-group-ID
#include <sys/types.h> #include <unistd.h> int setgid(gid_t gid);
If the process has appropriate privileges, setgid() sets the real group ID, effective group ID and the saved set-group-ID to gid.If the process does not have appropriate privileges, but gid is equal to the real group ID or the saved set-group-ID, setgid() function sets the effective group ID to gid; the real group ID and saved set-group-ID remain unchanged.
Any supplementary group IDs of the calling process remain unchanged.
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error.
The setgid() function will fail if:
- [EINVAL]
- The value of the gid argument is invalid and is not supported by the implementation.
- [EPERM]
- The process does not have appropriate privileges and gid does not match the real group ID or the saved set-group-ID.
None.
None.
None.
exec, getgid(), setuid(), <sys/types.h>, <unistd.h>.
Derived from Issue 1 of the SVID.