[Process] Zombie Processes left behind

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Process] Zombie Processes left behind

Boost - Users mailing list
Boost Team: 


We are trying to use boost process to have an always running process spawn child processes in a fire and forget manner (don't wait or block on the process that was just spawned). The issue we are running into is that the child processes become zombie processes when finished until the parent process completes. However in our system the parent process is never intended to complete, it is always running and listening. We have provided code snippets which give a simple example of the symptom we are experiencing. It's an infinite loop (imitating our always running process) that spawns processes that run and then become zombies instead of finishing (I included a sleep so it doesn't spawn processes too quickly). Please advise on whether there is something else we can do, if we are using child or spawn wrong, or if we are using boost process in a manner that it is not intended to be used. 

Thanks, 
Ryan Ruhge

 

 

#include <boost/process.hpp>

using namespace std;

int main() {

    while (true)

    {

        boost::process::spawn("sleep 10");

        sleep(5);

    }

}

 

 

 

#include <boost/process.hpp>

using namespace std;

int main() {

    while (true)

    {

        boost::process::child childProcess("sleep 10");

        childProcess.detach();

       sleep(5);

    }

}

 


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [Process] Zombie Processes left behind

Boost - Users mailing list

Hi,

 

  • We are trying to use boost process to have an always running process spawn child processes in a fire and forget manner (don't wait or block on the process that was just spawned).

 

In this case, the simplest solution is to ignore the SIGCHLD signal: https://stackoverflow.com/questions/16920887/zombie-process-sigchld-exit-in-unix

 

As in

 

#include <signal.h>

signal(SIGCHLD, SIG_IGN);

  • Stian

 


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users