private function createSavegame()
    {
        // the current process will become the savegame
        $this->savegame = \posix_getpid();

        $pid = \pcntl_fork();
        if ($pid < 0) {
            throw new \RuntimeException('Unable to create savegame fork');
        } elseif ($pid > 0) {
            // we're the savegame now... let's wait and see what happens
            \pcntl_waitpid($pid, $status);

            // worker exited cleanly, let's bail
            if (!\pcntl_wexitstatus($status)) {
                \posix_kill(\posix_getpid(), SIGKILL);
            }

            // worker didn't exit cleanly, we'll need to have another go
            $this->createSavegame();
        }
    }
private function createSavegame()
    {
        // the current process will become the savegame
        $this->savegame = \posix_getpid();

        $pid = \pcntl_fork();
        if ($pid < 0) {
            throw new \RuntimeException('Unable to create savegame fork');
        } elseif ($pid > 0) {
            // we're the savegame now... let's wait and see what happens
            \pcntl_waitpid($pid, $status);

            // worker exited cleanly, let's bail
            if (!\pcntl_wexitstatus($status)) {
                \posix_kill(\posix_getpid(), SIGKILL);
            }

            // worker didn't exit cleanly, we'll need to have another go
            $this->createSavegame();
        }
    }
private function createSavegame ( ) { // the current process will become the savegame $ this -> savegame = \ posix_getpid ( ) ; $ pid = \ pcntl_fork ( ) ; if ( $ pid < 0 ) { throw new \ RuntimeException ( 'Unable to create savegame fork' ) ; } elseif ( $ pid > 0 ) { // we're the savegame now... let's wait and see what happens \ pcntl_waitpid ( $ pid , $ status ) ; // worker exited cleanly, let's bail if ( ! \ pcntl_wexitstatus ( $ status ) ) { \ posix_kill ( \ posix_getpid ( ) , SIGKILL ) ; } // worker didn't exit cleanly, we'll need to have another go $ this -> createSavegame ( ) ; } }
Create a savegame fork.

The savegame contains the current execution state, and can be resumed in
the event that the worker dies unexpectedly (for example, by encountering
a PHP fatal error).
Create a savegame fork .