How to get current process name in linux?

后端 未结 7 1922
醉话见心
醉话见心 2020-12-01 05:49

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

7条回答
  •  没有蜡笔的小新
    2020-12-01 06:17

    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.

提交回复
热议问题