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
If successful, the value returned by getuid() represents the UID. Under unusual conditions getuid() can fail and will send error message CPE3418.
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. |
| [EUNKNOWN] |
Unexpected exception. |
Error Messages
The following messages may be sent from this function:
| Message ID | Error Message Text |
|---|---|
| CPE3418 E | Possible APAR condition or hardware failure. |
Related Information
- The <unistd.h> file (see Header Files for UNIX®-Type Functions)
Example
The following example gets the real UID.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
#include <unistd.h>
main()
{
uid_t uid;
uid = getuid(void);
printf("The real UID is: %u\n", uid);
}
Output:
The real UID is: 1957
API introduced: V3R1