Changing the Process Id in linux

拥有回忆 提交于 2019-12-02 04:02:20

问题


Is it possible to change the process id in linux operating system. If anyone know, please tell me.

Requirement :actually i want to bring up the back ground process to fore ground , which is being run under the init. So if i can change the process id or parent process id of the process. i can achieve my goal.


回答1:


No, it's not possible to do such a thing on Unix. You might be able to use fork to achieve this effect, but you have to tell us what you are trying to achieve.

pid_t pid;

/* I want a new PID. */
pid fork();
if (pid == 0) {
    /* getpid() will show I've got a new PID. */
else
    _exit(0); /* Parent or check for -1 (tinfoil hat)

Obviously, like I said before, you "might" be able to use this.




回答2:


Short answer: No.

Long answer: pocess id's(PID) are generated by the system, and are unique, and generated when the app starts. You cannot control the way they are generated...



来源:https://stackoverflow.com/questions/6692667/changing-the-process-id-in-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!