Android:如何在C语言中更改进程名称?

时间:2021-09-03 07:23:42

My Android program would starts a process written in C language. I need to modify this process' name.

我的Android程序将启动一个用C语言编写的进程。我需要修改这个进程的名字。

I used prctl(PR_SET_NAME) and it changed /proc/$pid/status, but /proc/$pid/cmdline did not changed.

我使用了prctl(PR_SET_NAME)并更改了/ proc / $ pid / status,但/ proc / $ pid / cmdline没有更改。

I searched and found out that I can modify the value of argv[0], but I don't know how to do this in an Android program.

我搜索并发现我可以修改argv [0]的值,但我不知道如何在Android程序中执行此操作。

1 个解决方案

#1


I use the "environ" pointer to find the argv[0] and change the name of process successfully.

我使用“environ”指针找到argv [0]并成功更改进程名称。

#1


I use the "environ" pointer to find the argv[0] and change the name of process successfully.

我使用“environ”指针找到argv [0]并成功更改进程名称。