geteuid()--Get Effective User ID


  Syntax
 #include <unistd.h>

 uid_t geteuid(void);  
  Service Program Name: QSYPAPI

  Default Public Authority: *USE

  Threadsafe: Yes

The geteuid() function returns the effective user ID (UID) of the calling thread. The effective UID is the user ID under which the thread is currently running. The effective UID of a thread may change while the thread is running.


Parameters

None.


Authorities

No authorization is required.


Return Value

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

Error Conditions

If geteuid() 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 effective UID.

#include <unistd.h>

main()
{
  uid_t ef_uid;

  if (-1 == (ef_uid = geteuid(void)))
     perror("geteuid() error.");
  else
     printf("The effective UID is: %u\n", ef_uid);

}

Output:

  The effective UID is: 1957

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