If getpwuid() function can't find an entry with a given uid (and therefore
function returns NULL pointer) what should the value of errno be?
If I clear errno and call getpwuid() with uid that doesn't exist on my
system I notice the following behaviour:
On Solaris 8 errno remains 0, on Linux it is set to 2 (ENOENT), on AIX it is
set to 2 (ENOENT) on AIX 4.2 and to 3 (ESRCH) on AIX 4.3.
POSIX itself says the following: "A null pointer shall be returned if the
requested entry is not found, or an error occurs. On error, errno shall be
set to indicate the error."
Since POSIX (at least in latest draft) doesn't mention ENOENT or ESRCH as
possible errors, I assume that Solaris comes closest to POSIX, but am not
really sure if that is indeed the best behaviour (since it means that user
doesn't exists if function returns NULL _and_ errno is 0).
To be or not to be is true. G. Boole