getpwuid 未设置 errno
getpwuid doesn't set errno
uid_t userId=getuid((;userId=999;//原因错误errno=0;passwd*pw=getpwuid(userId(;int n=错误号;//pw=NULL,n=0
在Linux中运行此代码时,我得到pw=NULL(应为(,errno=0。根据Linux文档http://linuxmanpages.com/man3/getpwuid.3.php,getpwuid必须设置errno。怎么了?
来自文档:
ERRORS 0 or ENOENT or ESRCH or EBADF or EPERM or ... The given name or uid was not found.
我看不出有什么问题。
根据您链接的文档:
0 or ENOENT or ESRCH or EBADF or EPERM or ...
The given name or uid was not found.
因此,errno==0对于未找到的uid完全有效。
相关文章:
- 为不同配置设置MSVC_RUNTIME_LIBRARY的正确方法是什么
- 在C++/Linux中设置单调时钟的一些技巧
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 嵌套在类中时无法设置成员数据
- 需要帮助设置在C++中使用的Potrace
- 如何在自删除后将对象设置为nullptr
- 将指针设置为"nullptr"并不能防止双重删除?
- 如何在Ubuntu中使用cmake设置qt4
- ld:bind_at_load和-bitcode_bundle(Xcode设置ENABLE_bitcode=YES)不能
- 如何在boost beast http请求中设置http头
- 如何解决gcc编译器优化导致的centos双编译器设置中的分段错误
- 设置SO_RCVTIMEO时,为什么recv返回-1并且errno=EINTR
- 每当设置了某些数学errno值时,如何引发异常
- 为什么从unistd.h调用crypt()函数会将errno设置为ENOENT?
- setsockopt 返回 -1:errno 设置为 0
- readlink 将 errno 设置为 ENOENT
- stdio 总是设置 errno 吗?
- ::socket 返回 0,并且 ::connect 将 errno 设置为 EBADF
- 抛出异常是否影响errno或设置最后错误码
- getpwuid 未设置 errno