如何在不执行 exec 系列函数的情况下更改子进程名称? [英] How to change child process name without excuting exec serie functions?

查看:45
本文介绍了如何在不执行 exec 系列函数的情况下更改子进程名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 mydaemon 的守护进程.现在我想有一个其他进程为我发送一些东西,当我 fork 一个子进程时,它与父进程具有相同的名称.如果没有 exec 函数,我怎么能有不同的进程名称?

I have a daemon process named mydaemon. Now I want to have an other process to send something for me , and when I fork a child process , it has the same name with the parent process. How can I have a different process name without exec function?

推荐答案

Linux下可以使用prctl()函数设置进程名:

Under Linux you can use the prctl() function to set the process name:

#include <sys/prctl.h>

prctl(PR_SET_NAME, "foobar");

这篇关于如何在不执行 exec 系列函数的情况下更改子进程名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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