Get the group ID
#include <sys/types.h> #include <unistd.h> gid_t getgid( void );
libc
The getgid() function gets the group ID for the calling process.
The calling process's group ID. This function can't fail.
/*
* Print the group id of a process.
*/
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main( void )
{
printf( "I belong to group ID %d\n", getgid() );
return EXIT_SUCCESS;
}
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |
getuid(), geteuid(), getegid()