没有变化的argv [0] Linux的变化过程名称 [英] change process name without change argv[0] in Linux

查看:318
本文介绍了没有变化的argv [0] Linux的变化过程名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要修改我用C langage程序的进程名。
我precise,这不是我想要改变线程的名称。
我想改变我的程序的名称,而唯一的解决办法,我发现是修改的值的argv [0]
我发现与使用prctl另一种解决方案(PR_SET_NAMENEWNAME),但这种方法是行不通的。

I need to modify the process name of my program in C langage. I precise, this is not the name of a thread that I want to change. I want change the name of my program, but the only solution, I found is to modify the value of argv[0]. I have found also another solution with prctl(PR_SET_NAME, "newname"), but this solution doesn't work.

所以,我需要帮助。
谢谢你。

So I need help. Thanks.

推荐答案

调用之间的差异使用prctl 并修改的argv [0] 是:

The differences between invoking prctl and modify argv[0] are:


  • 修改的argv [0] 修改信息的/ proc / $ PID / CMDLINE

  • 调用使用prctl(PR_SET_NAME)改变的/ proc / $ PID /状态信息

  • modify argv[0] changes information in /proc/$pid/cmdline
  • invoking prctl(PR_SET_NAME) changes information in /proc/$pid/status

这意味着你会得到你的过程中发出 PS -a PS -ax 差异名。

That means you will get difference name of your process issuing ps -a and ps -ax.

如果您在执行PS为不同的参数预计相同的进程名,你可以做他们两个(即,将的argv [0] 并调用使用prctl )。

If you expects same process name for different arguments while executing ps, you can do them both (i.e., change argv[0] and invoke prctl).

希望的答案有所帮助。

这篇关于没有变化的argv [0] Linux的变化过程名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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