getgid()--Get Real Group ID


  Syntax
 #include <unistd.h>

 gid_t getgid(void);  
  Service Program Name: QSYPAPI

  Default Public Authority: *USE

  Threadsafe: Yes

The getgid() function returns the real group ID (GID) of the calling thread. The real GID is the group ID under which the thread was created.

Note:: When a user profile swap is done with the QWTSETP API prior to running the getgid() function, the GID for the current profile is returned.


Parameters

None.


Authorities

No authorization is required.


Return Value

> 0
getgid() was successful. The value returned represents the GID.
>= 0
getgid() 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
getgid() was not successful. The errno global variable is set to indicate the error.

Error Conditions

If getgid() 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

See Code disclaimer information for information pertaining to code examples.

The following example gets the real GID.

#include <unistd.h>

main()
{
  gid_t gid;

  if (-1 == (gid = getgid(void)))
     perror("getgid() error.");
  else
     printf("The real GID is: %u\n", gid);

}

Output:

  The real GID is: 75

API introduced: V3R1

Top | UNIX-Type APIs | APIs by category