how to make ppid of a process as init without killing its parent
Hi all!!
Can i make parent of a process as init without killing that process's parent? Thanks in advance. Shantha |
You're going to have to give a little more detail. Also, what language is your program written in?
|
Hi
i want to make the parent of a process as init without killing the parent process which has created the process. I m using C on linux platform. |
Maybe man 3 daemon is what you're looking for. I've never tried it myself, but good luck.
|
The daemon() function will do it, sure. But it may be a bit too much, as the process will become a real daemon. That is, it looses any terminal connection so it will not be able to print any output never more. Also it looses its process group (whatever that means remains still unclear to me).
You can just kill the parent, and init will adopt your process. If you don't want to have the parent killed, because it is your shell you don't want to exit, you can fork() your program, and just exit the parent. Like this: Code:
#include <stdio.h> |
You can also do this to shell scripts.
For example, when I want to be root on my computer, I start an xterm with a red color. But I also don't want the root-xterm to exit when I exit the shell it was started from (its parent process). So I had a shell-script: Code:
#!/bin/bash |
Hi Hko
in your code the parent of the process is killed. Is there any way to make the parent of the forked process as init. I think u have undertood my question. I dont want to kill any process. Is there any way of doing it in linux using C. |
Quote:
Quote:
Quote:
Quote:
What happens in the code I posted is:
|
Hi Hko
Thanks for your replies. What i want is after the fork both child and parent should be running(not even exit) but only the parent of the child should be init. |
AFAIK this is the only way.
If you want to keep two processes running, just fork another that does not exit... |
Thank for all the replies sent.
Bye, Shantha |
All times are GMT -5. The time now is 02:12 AM. |