如何在Linux中获取当前进程名? [英] How to get current process name in linux?

查看:163
本文介绍了如何在Linux中获取当前进程名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能在C程序的名字吗?相同的名称,这是在的/ proc / $ PID /状态。我不想解析该文件。是否有这样做的任何编程方式?

How can I get the process name in C? The same name, which is in /proc/$pid/status. I do not want to parse that file. Is there any programmatic way of doing this?

推荐答案

这是不是由的argv [0] 或实际上你可以阅读的/ proc /自/状态。或者你可以使用 GETENV(_),不知道谁是设置以及如何可靠的是。

It's either pointed to by the argv[0] or indeed you can read /proc/self/status. Or you can use getenv("_"), not sure who sets that and how reliable it is.

这篇关于如何在Linux中获取当前进程名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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