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

If successful, the value returned by getgid() represents the GID. Under unusual conditions getgid() can fail and will send error message CPE3418.

> 0
The value returned represents the GID.
>= 0
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.

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 Messages

The following messages may be sent from this function:


Related Information


Example

The following example gets the real 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 gid;

  gid = getgid(void);
  printf("The real GID is: %u\n", gid);

}

Output:

  The real GID is: 75

API introduced: V3R1

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