getegid()--Get Effective Group ID


  Syntax
 #include <unistd.h>

 gid_t getegid(void);  
  Service Program Name: QSYPAPI

  Default Public Authority: *USE

  Threadsafe: Yes

The getegid() function returns the effective group ID (GID) of the calling thread. The effective GID is the group ID under which the thread is currently running. The effective GID of a thread may change while the thread is running.


Parameters

None.


Authorities

No authorization is required.


Return Value

> 0
getegid() was successful. The value returned represents the effective GID.
>= 0
getegid() was successful. If there is no GID, the user ID has no group profile associated with it and returns 0. Otherwise, if there is a group profile, the API returns the GID of the group profile.
-1
getegid() was not successful. The errno global variable is set to indicate the error.

Error Conditions

If getegid() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.

Error condition Additional information
[EAGAIN]

Internal object compressed. Try again.

[EDAMAGE]

The user profile associated with the thread GID or an internal system object is damaged.

[ENOMEM]

The user profile associated with the thread GID has exceeded its storage limit.


Related Information


Example

The following example gets the effective GID.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#include <unistd.h>

main()
{
  gid_t ef_gid;

  if (-1 == (ef_gid = getegid(void)))
     perror("getegid() error.");
  else
     printf("The effective GID is: %u\n", ef_gid);

}

Output:

  The effective GID is: 75

API introduced: V3R1

[ Back to top | UNIX-Type APIs | APIs by category ]