global $status;
    $status->hangOn();
}
register_shutdown_function('master_shutdown');
$tasks = array();
do {
    // get the first task in the queue
    if (!$id) {
        foreach ($tasks as $key => $task) {
            $id = $key;
            break;
        }
    }
    if ($status->getInfo($id) != Status::DONE) {
        $status->updateStatus($id, Status::PROCESSING);
        process($id);
        $status->updateStatus($id, Status::DONE);
    }
    // continue while existing pending tasks
    $id = null;
    $tasks = $status->getNotDoneTasks();
} while (count($tasks));
sleep(2);
// give time to frontend to recover updated status
// frees status file indicating that this process has been terminated
$status->freeStatusFile();
function process($id)
{
    // simulate a long long process
    sleep(120);
}