getgid() — Get the real group ID

Standards

Standards / Extensions C or C++ Dependencies

POSIX.1
XPG4
XPG4.2
Single UNIX Specification, Version 3

both  

Format

#define _POSIX_SOURCE
#include <unistd.h>

gid_t getgid(void);

General description

Finds the real group ID (GID) of the calling process.

Returned value

Returns the real group ID of the calling process. It is always successful.

There are no documented errno values.

Example

CELEBG07
⁄* CELEBG07

   This example gets the real group ID.

 *⁄
#define _POSIX_SOURCE
#include <sys⁄types.h>
#include <stdio.h>
#include <unistd.h>

main() {
  printf("my group id is %d\n", (int) getgid());
}
Output
my group id is 500

Related information