linux从内核中的pid获取进程名称 [英] linux get process name from pid within kernel

查看:1530
本文介绍了linux从内核中的pid获取进程名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我已经在内核中使用sys_getpid()来获取进程ID 如何从内核结构中找出进程名称?它是否存在于内核中?

非常感谢

解决方案

comm的成员,其中包含executable name excluding path.

从此文件获取当前宏将为您获取启动当前进程的程序的名称(如insmod/modprobe).

使用以上信息,您可以使用获取名称信息.

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

解决方案

struct task_struct contains a member called comm, it contains executable name excluding path.

Get current macro from this file will get you the name of the program that launched the current process (as in insmod / modprobe).

Using above info you can use get the name info.

这篇关于linux从内核中的pid获取进程名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆