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
Asked
Active
Viewed 1,985 times
1 Answers
2
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.

Tsyvarev
- 60,011
- 17
- 110
- 153
-
doesn't `gid` refers to `group id` ? – bawejakunal Sep 24 '16 at 23:39
-
Looks like it was misprint. Now it is fixed. Thanks for pointing out. – Tsyvarev Sep 26 '16 at 07:28