1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-11-03 17:14:44 +00:00

implement proper child cleanup

This commit is contained in:
Oliver Giles
2016-07-25 14:59:45 +03:00
parent 7b7de751e3
commit 2ea27d46ed
6 changed files with 68 additions and 42 deletions

View File

@@ -23,6 +23,7 @@
#include <iostream>
#include <unistd.h>
#include <signal.h>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
@@ -68,7 +69,13 @@ bool Run::step() {
int pfd[2];
pipe(pfd);
pid_t pid = fork();
if(pid == 0) {
if(pid == 0) { // child
// reset signal mask (SIGCHLD blocked in Laminar::start)
sigset_t mask;
sigemptyset(&mask);
sigaddset(&mask, SIGCHLD);
sigprocmask(SIG_UNBLOCK, &mask, NULL);
close(pfd[0]);
dup2(pfd[1], 1);
dup2(pfd[1], 2);