Setegid

Name
seteuid, setegid - set effective user or group ID

Synopsis
int seteuid(uid_t euid); int setegid(gid_t egid);
 * 1) include 
 * 2) include 

Description
seteuid sets the effective user ID of the current process. Unprivileged user processes may only set the effective user ID to the real user ID, the effective user ID or the saved set-user-ID.

Precisely the same holds for setegid with "group" instead of "user".

Return Value
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

Errors
EPERM

The current process is not privileged (Linux: does not have the CAP_SETUID capability in the case of seteuid, or the CAP_SETGID capability in the case of setegid) and euid (resp. egid) is not the real user (group) ID, the effective user (group) ID, or the saved set-user-ID (saved set-group-ID).