getuid()--Get Real User ID


  Syntax
 #include <unistd.h>

 uid_t getuid(void);  
  Service Program Name: QSYPAPI

  Default Public Authority: *USE

  Threadsafe: Yes

The getuid() function returns the real user ID (UID) of the calling thread. The real UID is the user ID under which the thread was created.

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


Parameters

None.


Authorities

No authorization is required.


Return Value

0 or > 0
getuid() was successful. The value returned represents the UID.
-1
getuid() was not successful. The errno global variable is set to indicate the error.

Error Conditions

If getuid() 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 UID or an internal system object is damaged.

[ENOMEM]

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


Related Information


Example

See Code disclaimer information for information pertaining to code examples.

The following example gets the real UID.

#include <unistd.h>

main()
{
  uid_t uid;

  if (-1 == (uid = getuid(void)))
     perror("getuid() error.");
  else
     printf("The real UID is: %u\n", uid);

}

Output:

  The real UID is: 1957

API introduced: V3R1
Top | UNIX-Type APIs | APIs by category