Angus Leeming <[EMAIL PROTECTED]> writes:

> 
> ECHILD suggests that the zombie has been reaped already by a previous
> invocation of waitpid. Are you invoking waitpid yourself? (Don't do that.)

Nope, I just do:

int SnippetConversion::startAndWait(...) 
{
        command_ = prepareCommand(...);
        support::Forkedcall call;
        int ret = call.startscript(support::ForkedProcess::Wait, command_);
        
        if (ret != 0) {
                ...
        }
        return ret;  
}

which calls:

int Forkedcall::startscript(Starttype wait, string const & what)
{
        if (wait != Wait) {
                retval_ = startscript(what, SignalTypePtr());
                return retval_;
        }

        command_ = what;
        signal_.reset();
        return run(Wait);
}

and then:

int ForkedProcess::run(Starttype type)
{
        retval_  = 0;
        pid_ = generateChild();
        if (pid_ <= 0) { // child or fork failed.
                retval_ = 1;
                return retval_;
        }

        switch (type) {
        case Wait:
                retval_ = waitForChild();
                break;
        case DontWait: 
                ...
        }
        return retval_;
}

which ends in:

int ForkedProcess::waitForChild()
{
        // We'll pretend that the child returns 1 on all error conditions.
        retval_ = 1;
        int status;
        bool wait = true;
        while (wait) {
                pid_t waitrpid = waitpid(pid_, &status, WUNTRACED);
                if (waitrpid == -1) {
                        lyxerr << "LyX: Error waiting for child:"
                               << strerror(errno) << endl;
                        wait = false;
                }
        ...
        }
        ...
}

> LyX 1.4 has a signal_handler for SIGCHLD signals and will reap zombies
> automatically unless the spawn-and-block code is protected by a call to
> sigprocmask to block the signal.

So maybe you should do that in ForkedProcess::run() ?

Ciao
/Andreas

Reply via email to