[Previous]
[Contents]
[Next]

setegid()

set the effective group ID for a process

Synopsis:

#include <unistd.h>
int setegid( gid_t gid );

Description:

The setegid() function allows the calling process to set the effective group ID. The real and saved group ID aren't changed.

Returns:

0
Success.
-1
An error occurred. errno is set to indicate the error.

Errors:

EINVAL
The value of gid is invalid.
EPERM
The process doesn't have appropriate privileges, and gid doesn't match the real group ID.

Examples:

/*
 * This process sets its effective group ID to 2.
 */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

void main()
  {
    gid_t oegid;

    oegid = getegid();
    if( setegid( 2 ) == -1 ) {
      perror( "setegid" );
      exit( EXIT_FAILURE );
    }
    printf( "Was effective group %d, is 2\n", oegid );
    exit( EXIT_SUCCESS );
  }

Classification:

UNIX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

errno, seteuid(), setgid(), setuid()


[Previous]
[Contents]
[Next]