【问题标题】:Get the executable file name (comm in task_struct) from a PID从 PID 获取可执行文件名(task_struct 中的 comm)
【发布时间】:2021-01-19 00:00:56
【问题描述】:

我正在学习Linux中的操作系统,并且想获取可执行文件名。 我知道我可以从 task_struct 中的 'comm' 获取它,但我不知道如何获取它。

谢谢!

【问题讨论】:

    标签: linux-kernel operating-system system-calls


    【解决方案1】:

    您想在用户模式还是内核模式下执行此操作?

    在用户模式下,使用 procfs: https://unix.stackexchange.com/questions/449300/get-application-name-from-pid

    在内核模式下,使用pid_task 获取task_struct 指针,然后读取您想要的任何内容: Efficient way to find task_struct by pid

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-31
      • 1970-01-01
      • 1970-01-01
      • 2016-01-02
      • 1970-01-01
      • 1970-01-01
      • 2012-08-29
      相关资源
      最近更新 更多