linux get process name from pid within kernel

前端 未结 4 1124
暗喜
暗喜 2021-01-05 07:30

hi i have used sys_getpid() from within kernel to get process id how can I find out process name from kernel struct? does it exist in kernel??

thanks very much

4条回答
  •  鱼传尺愫
    2021-01-05 07:57

    you can look at the special files in /proc//

    For example, /proc//exe is a symlink pointing to the actual binary.

    /proc//cmdline is a null-delimited list of the command line, so the first word is the process name.

提交回复
热议问题