I would like to get uid of a pid. Please note that the uid that I want to get is NOT of the current process. Please let me know if you have an idea. Maybe can I get it by reuse the function of /proc/[pid]/status read function in kernel? //Bruce
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Search process descriptor (
struct task_struct
) with given pid.Use
task->cred->uid
.
Struct struct task_struct
is defined in include/linux/sched.h
. Struct struct cred
is defined in include/linux/cred.h
.
Note, that iterating through processes and reading process's credentials should be done under RCU-critical section.