Updated: April 19, 2023 |
Get information about the user with a given name
#include <sys/types.h> #include <pwd.h> int getpwnam_r( const char *name, 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 getpwnam_r() function is a reentrant version of getpwnam(). It gets information about the user with the given name.
The getpwnam_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 the given name.
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 getpwnam_r() function can also return any error code that the following functions indicate:
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |