Sign in to follow this  
rish2005

defunct daemon process!!

Recommended Posts

Quote:
Original post by rish2005
how can i assure that daemon process which is being run as init child,can be removed immediately from system when it goes defunct or to avoid daemon process becoming defunt?


A daemon cannot become a defunct (aka: zombie) process because a daemon has no parent and has been adopted by init.

A zombie or defunct process is a process that has terminated and is waiting to give it's status back to the parent. The parent is still running and hasn't checked the status using wait.

A process owned by init (either directly spawned by init or a daemon adopted by init) will have the status checked automatically, and therefore not be defunct.

frob.

Share this post


Link to post
Share on other sites
I should have also mentioned...

You probably aren't creating your daemon properly.

Your app needs to create a new process, then have the new process spawn another child and die. The grandchild is orphaned since it has no running parent. The orphaned process gets adopted by init, and if it is still running becomes a daemon.

frob.

Share this post


Link to post
Share on other sites
thnks for the answer..
My daemon process is the child of init and init has the responsibility to remove it, once it turns zombie. But I want to ask why the daemon process which is child of init turns zombie in the first place. What measures I have to take to avoid this?
rish

Share this post


Link to post
Share on other sites
Every process becomes a zombie when it dies. It's just that normally they only stay that way for a very short time until their parent notices this.

The only thing remaining from a zombie process is its exit code. This is what wait() retrieves.

Processes in the zombie state cannot run, use no memory and cannot have any open files. Therefore they use up very little system resource (but obviously *SOME* given that they use up space in the kernel process list).

Mark

Share this post


Link to post
Share on other sites
I am creating the daemon process by adding the entry to inittab and doing initq.
Is there something something wrong with this approach. Also my daemon process is creating and using shared memory. If it turns zombie and before being removed by init waht happened to shared memory or open file descriptors. Do they get closed when process turns zombie?
rish

Share this post


Link to post
Share on other sites
Quote:
Original post by frob
I should have also mentioned...

You probably aren't creating your daemon properly.
Quote:
Original post by rish2005
I am creating the daemon process by adding the entry to inittab and doing initq.
Is there something something wrong with this approach. Also my daemon process is creating and using shared memory. If it turns zombie and before being removed by init waht happened to shared memory or open file descriptors. Do they get closed when process turns zombie?
rish


Very likely something wrong with your approach.

Find and read the daemon HOWTO found here, (or from your favorite HOWTO source).

A daemon is a properly orphaned, forked process, that requests it's own session ID. I have not heard of creating daemons the way you suggest.

A daemon should not become a zombie, except for the instant between when it dies and init cleans it up.

Share this post


Link to post
Share on other sites
Sign in to follow this