How to get current process name in linux?

后端 未结 7 1932
醉话见心
醉话见心 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 05:53

    Look at the value of argv[0] which was passed to main. This should be the name under which your process was invoked.

提交回复
热议问题