进程名称来自其在 linux 中的 pid [英] Process name from its pid in linux

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

问题描述

如何从他的 pid 中获取进程名称?例如,我执行 cat file1.txt,但我想找出该 cat 命令及其参数,因为它在系统中的 pid.是否有一个结构来确定它或类似的东西?有什么想法吗?

How to get a process name from his pid ? For example I execute cat file1.txt, but I want to figure out that cat command and its arguments since its pid in the system. Is there a struct to determine it or something similar? Any idea?

推荐答案

没有任何通用的方法可以做到这个 unix.
每个操作系统都有不同的处理方式,有些非常困难.不过你提到了Linux.对于 Linux,信息位于/proc 文件系统中.
要获取进程 ID 9999 的命令行,请阅读文件 /proc/9999/cmdline.

There is not any general way to do this unix.
Each OS has different ways to handle it and some are very hard. You mention Linux though. With Linux, the info is in the /proc filesystem.
To get the command line for process id 9999, read the file /proc/9999/cmdline.

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

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