Reputation: 43321
uid_t userId = getuid(); userId = 999; // cause error errno = 0; passwd* pw = getpwuid(userId); int n = errno; // pw = NULL, n = 0
Running this code in Linux, I get pw = NULL (expected), and errno = 0. According to Linux documentation http://linuxmanpages.com/man3/getpwuid.3.php, getpwuid must set errno. What is wrong?
Upvotes: 3
Views: 730
Reputation: 53320
According to the documentation you linked:
0 or ENOENT or ESRCH or EBADF or EPERM or ...
The given name or uid was not found.
So errno == 0 is perfectly valid for a uid not found.
Upvotes: 3
Reputation: 799082
From the documentation:
ERRORS 0 or ENOENT or ESRCH or EBADF or EPERM or ... The given name or uid was not found.
I fail to see a problem.
Upvotes: 4