John Levon wrote:

> On Mon, Mar 22, 2004 at 06:54:15PM +0000, Angus Leeming wrote:
> 
>> It turns out that QEventLoop exists only for Qt >= 3.1. I'm running
>> RH8 here (Qt 3.0.5). For Qt < 3.1, the trick seems to be to use a
>> QTimer with 0 timeout. That *does* work.
> 
> Excuse me if I'm misunderstanding, is this going to busy loop when
> we've no events on the queue ?

Yes.

> We only need to reap children every 10 minutes or whatever

Then we go back to the timer and the whole thing has been a waste of 
time?

Hmmm. Maybe not.

It is trivially easy to execute code from the signal handler. Maybe 
that's OK in this case? The main code is not going to be in a fragile 
state because SIGCHLD is not an error. I guess that we still need 
guards to prevent us re-entering the 'clean-up after any finished 
children' code whilst we're still processing a previous signal.

What do you think to something like this:

void child_handler(int)
{
        // A flag to prevent us reaching the while loop
        // if a previous signal is still being executed.
        static bool processing_signal = false;
        // A flag to control exit from the while loop.
        bool process_signal = true;

        if (processing_signal)
                return;
        processing_signal = true;

        while (process_signal) {
                process_signal = false;
                ForkedcallController::get().handleCompletedProcesses();
        }

        processing_signal = false;
}

-- 
Angus

Reply via email to