Click to See Complete Forum and Search --> : daemon's in unix


hemanth
05-23-2002, 06:51 AM
hello guys,
well i'm involved with an issue of porting an application onto linux from SCO.on the SCO system i hv used setpgrp to make a child process a daemon n i as child can comm with the parent whilst in linux with setpgrp the process doesn't become a daemon.i hv used the daemon(1,1) command but there a problem here.i don't hv the parent id.getppid() returns 1(id of init process right?).so i'm having to pass the parent id to the child.is there no other go with which the child process can get the parent id....like maybe some command or something....do post what u feel abt this guys n if u need some more info u can always mail me.
i'm a new member n hope i get some replies.
cheers.

furrycat
05-26-2002, 01:53 AM
My advice on creating daemon processes is: DON'T.

I'm a system administrator. If I want to run your program in the background I will launch it from the shell and background it with "yourprog &"

But what if I don't want it to background itself (which I don't - ALL my long-running processes are monitored by DJB's daemontools software, which requires them to stay in the foreground)?

I can put a non-daemon program into the background easily but the best I can do is start a new process to check that yours is running every so often. Hacky and inefficient.

Of course it's your program and you are entirely free to ignore my advice. I say again though, I'm a professional sysadmin and there is NOTHING on unix I hate more than programs which put themselves in the background. One hackaround would be to get the process ID before you fork() and store it in a static variable. Ugly but it would work. There must be a better solution but (for the reasons stated above) I neither know nor care what it is :-)

aravi
05-29-2002, 04:30 AM
You could also try to work out why it needed to run like that under SCO and whether or not it needs to under Linux.

You have has many options as you have the skill, knowledge and intelligence to find.