Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

getpwuid - get user ID

&pagelevel(4)&pagelevel

Syntax

#include <pwd.h>

Optional
#include <sys/types.h> (End)

struct passwd *getpwuid(uid_t uid);

Description

getpwuid() searches the user catalog for an entry in which the pw_uid component (see thepasswd structure in pwd.h) matches uid. Subsequent structures with the same user ID are
not found.

Return val.

Pointer to a structure of type passwd (see pwd.h



if successful.

 

Null pointer

if an error occurs when reading or no matching entry with a pw_uid component matching uid was found in the user catalog.

Errors

getpwuid() fails if: 

 

EFAULT

An error occurs when creating the passwd structure.

 

ENOENT


Notes

The return value may point to a static area which may be overwritten by a subsequent call to cuserid, getpwnam or getpwuid.

Applications wishing to check for error situations should set errno to 0 before calling getpwuid().

The three names associated with the current process can be determined as follows:
getpwuid(geteuid()) returns the name associated with the effective user ID of the process; getlogin() returns the name associated with the current login activity; and getpwuid(getuid()) returns the name associated with the real user ID of the process.

See also

cuserid(), getpwuid_r(), getpwnam(), geteuid(), getuid(), getlogin(), limits.h, pwd.h, sys/types.h, and the manual "POSIX Basics" [1 (Related publications)].