【发布时间】:2021-01-19 00:00:56
【问题描述】:
我正在学习Linux中的操作系统,并且想获取可执行文件名。 我知道我可以从 task_struct 中的 'comm' 获取它,但我不知道如何获取它。
谢谢!
【问题讨论】:
标签: linux-kernel operating-system system-calls
我正在学习Linux中的操作系统,并且想获取可执行文件名。 我知道我可以从 task_struct 中的 'comm' 获取它,但我不知道如何获取它。
谢谢!
【问题讨论】:
标签: linux-kernel operating-system system-calls
您想在用户模式还是内核模式下执行此操作?
在用户模式下,使用 procfs: https://unix.stackexchange.com/questions/449300/get-application-name-from-pid
在内核模式下,使用pid_task 获取task_struct 指针,然后读取您想要的任何内容:
Efficient way to find task_struct by pid
【讨论】: