如何解析/proc/pid/cmdline [英] How to parse /proc/pid/cmdline

查看:764
本文介绍了如何解析/proc/pid/cmdline的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Linux上拆分进程的cm​​dline,但看来我不能依靠它用'\ 0'字符分隔.您知道为什么有时使用'\ 0'字符作为分隔符,有时使用常规空格吗?

I'm trying to split the cmdline of a process on Linux but it seems I cannot rely on it to be separated by '\0' characters. Do you know why sometimes the '\0' character is used as separator and sometimes it is a regular space?

您知道检索可执行文件名称及其路径的任何其他方法吗?我一直在尝试使用"ps"获取此信息,但是它总是返回完整的命令行,并且可执行文件名被截断.

Do you know any other ways of retrieving the executable name and the path to it? I have been trying to get this information with 'ps' but it always returns the full command line and the executable name is truncated.

谢谢.

推荐答案

使用strings

$ cat /proc/self/cmdline | strings -1
cat
/proc/self/cmdline

这篇关于如何解析/proc/pid/cmdline的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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