Get information about the user with a given ID
#include <sys/types.h> #include <pwd.h> int getpwuid_r( uid_t uid, struct passwd* pwd, char* buffer, size_t bufsize, struct passwd** result );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The getpwuid_r() function is a reentrant version of getpwuid(). It lets a process gain more knowledge about user with the given uid.
If _POSIX_THREAD_SAFE_FUNCTIONS is defined, the getpwuid_r() function updates the passwd structure pointed to by pwd and stores a pointer to that structure at the location pointed by result. The structure contains an entry from the user database with a matching uid.
The function stores a NULL pointer at the location pointed by result on error or if it can't find the requested entry.
Zero for success, or an error number.
The getpwuid_r() function uses the following functions, and as a result, errno can be set to an error for any of these calls:
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
getlogin(), getpwent(), getpwent_r(), getpwnam(), getpwnam_r(), getpwuid()