Standards / Extensions | C or C++ | Dependencies |
---|---|---|
POSIX.1a |
both |
#define _POSIX1_SOURCE 2
#include <unistd.h>
int setegid(gid_t gid);
Sets the effective group ID (GID) of a process to gid, if gid is equal to the real GID or the saved set GID of the calling process, or if the process has appropriate privileges. The real GID, the saved set GID, and any supplementary GIDs are not changed.
If successful, setegid() returns 0.
⁄* CELEBS02
This example changes your effective GID.
*⁄
#define _POSIX1_SOURCE 2
#include <unistd.h>
#include <stdio.h>
main() {
printf("your effective group id is %d\n", (int) getegid());
if (setegid(500) != 0)
perror("setegid() error");
else
printf("your effective group id was changed to %d\n",
(int) getegid());
}
your effective group id is 512
your effective group id was changed to 500