最佳答案
您实际上想要/ proc / self / status,它将为您提供有关当前执行过程的信息.
原文链接:https://www.f2er.com/linux/440759.html这是一个例子:
$cat /proc/self/status
Name: cat
State: R (running)
Tgid: 17618
Pid: 17618
PPid: 3083
TracerPid: 0
Uid: 500 500 500 500
Gid: 500 500 500 500
FDSize: 32
Groups: 10 488 500
VmPeak: 4792 kB
VmSize: 4792 kB
VmLck: 0 kB
VmHWM: 432 kB
VmRSS: 432 kB
VmData: 156 kB
VmStk: 84 kB
VmExe: 32 kB
VmLib: 1532 kB
VmPTE: 24 kB
Threads: 1
SigQ: 0/32268
SigPnd: 0000000000000000
Shdpnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 0000000000000000
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
cpus_allowed: 00000003
Mems_allowed: 1
voluntary_ctxt_switches: 0
nonvoluntary_ctxt_switches: 3
您可能想查看Uid和Gid行上的第一个数字.您可以通过查看/ etc / passwd查找哪些uid号码映射到哪个用户名,或调用相关函数将uid映射到您正在使用的任何语言的用户名.