问题描述
新父母总是初始化"还是是否有某种方法可以控制谁成为新父母?
Is the new parent always "init" or is there some way to control who gets to be the new parent?
维基百科似乎表明它总是"init".我真的希望事实并非如此.我已经尝试过使用setpgid和setsid可以想到的所有方法,但是没有运气.现在,我看到了这篇维基百科文章,我需要建议.
Wikipedia seems indicates that it's always "init". I really hope that this is not the case. I have tried everything I can think of with setpgid and setsid, but no luck. And now that I see this wikipedia article I need advice.
我问的原因是因为我正在制作一个运行许多辅助进程的Mac应用程序.我希望这些工作进程在任务管理器.一些工作程序以不同的用户身份运行,在Mac OS X上,我需要分叉两次以将特权传递给子进程.因为我是双叉"的,所以这些工人当前是作为重做者运行的,因此当与任务管理器一起查看时,我看到这些工人将"init"作为其父进程.
The reason I'm asking is because I'm making a Mac app that runs a number of worker processes. I want these worker processes to appear as children of the main process in the process-hierarchy of the task manager. Some of the workers run as different users and on Mac OS X I need to fork twice to pass privileges to the child process. Because I "double fork" the workers currently run as deamons, and when looking with task manager I see the workers are having "init" as their parent process.
推荐答案
init
始终采用孤立的子代.没有Unix
将父级更改为某些非初始化进程的方法.
Orphaned children are always adopted by init
. There is no Unix
way of changing the parent to some non-init process.
从Linux 3.4开始,这不再严格成立.仍然没有可移植的Unix方式,但是正如Andy Lutomirski指出的那样,Linux 3.4为PR_SET_CHILD_SUBREAPER ="noreferrer"> prctl
.
As of Linux 3.4 this is no longer strictly true. There's still no portable Unix way of doing this but as Andy Lutomirski points out Linux 3.4 adds PR_SET_CHILD_SUBREAPER
for prctl
.
这篇关于流程重新父母:控制谁是新父母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!