gtpc2m42C/C++ Language Support User's Guide

getuid-Get the Real User ID

This function finds the real user ID (UID) of the calling function's process.

Format

#include <unistd.h>
uid_t getuid(void);

Normal Return

The getuid function returns the real user ID of the calling function's process. It is always successful.

Error Return

Not applicable.

Programming Considerations

None.

Examples

The following example provides information for the user ID of the caller.

#include <unistd.h>
#include <stdio.h>
 
int main(void) {
      printf ( "My real user id is %d\n", (int) getuid() );
      return 0;
}

The getuid function returns the following information for the user ID of the calling function:

My real user id is 500

Related Information