gpt4 book ai didi

c++ - getpwuid 不设置 errno

转载 作者:太空狗 更新时间:2023-10-29 20:17:51 26 4
gpt4 key购买 nike

    uid_t userId = getuid();    userId = 999;               // cause error    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。怎么了?

最佳答案

来自文档:

ERRORS
0 or ENOENT or ESRCH or EBADF or EPERM or ...
The given name or uid was not found.

我没看出问题。

关于c++ - getpwuid 不设置 errno,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5769161/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com