改变进程的父 [英] changing a process's parent

查看:132
本文介绍了改变进程的父的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能改变一个进程的父?

例如:?父具有Child B级我可以做B的母公司是INIT进程不杀

Is it possible to change a process parent?
ex: parent A has Child B can I make the parent of B is the Init process without killing A?

推荐答案

不从进程B之外。

从进程B的内部,你可以调用fork使您的要求的副本,然后让原来的出口。当这种情况发生了新的副本B2将不会是一个的孩子,其父将被设置为1(init进程)。

From inside process B, you can call fork which makes a copy of your process, then let the original exit. When that happens the new copy B2 will not be a child of A, its parent will be set to 1 (the init process).

这篇关于改变进程的父的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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