uid_t userId = getuid(); userId = 999; // 引起错误
errno = 0; passwd* pw = getpwuid(userId);
int n = errno; // pw = NULL, n = 0
在Linux中运行此代码,我得到了pw = NULL(预期),errno = 0。根据Linux文档http://linuxmanpages.com/man3/getpwuid.3.php,getpwuid必须设置errno。有什么问题吗?
uid_t userId = getuid(); userId = 999; // 引起错误
errno = 0; passwd* pw = getpwuid(userId);
int n = errno; // pw = NULL, n = 0
在Linux中运行此代码,我得到了pw = NULL(预期),errno = 0。根据Linux文档http://linuxmanpages.com/man3/getpwuid.3.php,getpwuid必须设置errno。有什么问题吗?