The getgid(2) and getegid(2) Functions

The id(1) command must determine the gid it is operating under. The getgid(2) and getegid(2) functions are shown in the synopsis for this purpose:

#include <sys/types.h>
#include <unistd.h>

gid_t getgid(void);

gid_t getegid(void);

The getgid(2) function returns the real group ID number, and the getegid(2) function returns the effective group ID. There are no errors to check; these functions always succeed.

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.