Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6830495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:37:28+00:00 2026-05-26T22:37:28+00:00

So I want to do the following: Set up a daemon that forks a

  • 0

So I want to do the following:
Set up a daemon that forks a bunch of processes.

So the Daemon forks a bunch of processes
then forks another bunch of processes

the problem is the child processes might take a long time to exit. How do I prevent zombie children if the parent process has other work to do despite forking children?

The parent process (the daemon) does something like this:

while(true)
{
SQL QUERY EXECUTED

   while(mysql_fetch_array)
   {
       Fork children
   }
}

The problem is how can I wait for the children processes to exit if the parent process has to do other work besides forking children and if the children take a long time to exit.

I am using the System daemon PEAR function to create the daemon and the pcntl_fork function to create the processes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:37:29+00:00Added an answer on May 26, 2026 at 10:37 pm

    I don’t remember where I saw this:

    Parent forks child
      Waits until child is dead  (this won't take long, see ahead)
      Goes on
    
    Child does only 2 things:
      Forks a grandchild
      Exits
    
    Grandchild does whatever work is needed
      Exits
    

    The trick is that when the Granchild dies, its parent (one of your Children) is already dead. But someone has to be notified for the death. It appears that in Linux systems, it’s not the grandparent that is notified but the grand-grand-…-grandparent of all. And because that process knows its job, it periodically checks for dead children and does not allow them to become zombies.

    Here’s a link with explanation: http://fixunix.com/unix/533215-how-avoid-zombie-processes.html

    When a process’s parent terminates, the “init” process takes over as its
    parent. So when the child process exits, the grandchild loses its
    parent, and is adopted by init. Init always reaps its dead children, so
    they don’t become zombies.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to do the following: I have a Daemon set up that every
Imagine I have the following string : set(SEXY_STRING I love CMake) then I want
I want to set an observer for each of the following checkboxes: <div id=listr>
I've set up the following for loop to accept 5 test scores. I want
I set the content view for the following window and now i want to
In the following code, I want to set Onclick Listeners on some elements of
I have the following property public MyType MyProperty {get;set;} I want to change this
I have some following set of data from where I want to select Top
I have the following set-up: A Window that has a splitView in which I
I have the following set up on my page: I want to position the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.