原帖由 xi2008wang 于 2007-12-25 23:30 发表
兄弟!我今天也正好看到这一节了
郁闷啊,我把它看了三遍,但我还是云里雾里.........
![]()
![]()
![]()
我的理解是:它们虽然是两个指针变量,但它们都指向同一个静态的passwd结构变量
ps:APUE2中文P1 ...
原帖由 xiaozhu2007 于 2007-12-25 23:48 发表
我理解的,getpwnam函数自己申请一个passwd结构的变量,然后只要在同一个进程中的任何地方和时间执行的时候都将得到的口令文件信息存放在这个结构中然后返回这个passwd结构的地址,所以虽然在main中和sig_handl ...
原帖由 xiaozhu2007 于 2007-12-25 23:48 发表
我理解的,getpwnam函数自己申请一个passwd结构的变量,然后只要在同一个进程中的任何地方和时间执行的时候都将得到的口令文件信息存放在这个结构中然后返回这个passwd结构的地址,所以虽然在main中和sig_handl ...
map 3p getpwnam
APPLICATION USAGE
Three names associated with the current process can be determined:
getpwuid( geteuid()) returns the name associated with the effective
user ID of the process; getlogin() returns the name associated with
the current login activity; and getpwuid( getuid()) returns the name
associated with the real user ID of the process.
The getpwnam_r() function is thread-safe and returns values in a user-
supplied buffer instead of possibly using a static data area that may
be overwritten by each call.
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |