pcntl_sigwaitinfo example

// Amount of microseconds we should wait without slowing things down too much         $clockDelay = 50000;

        $key = new Key(uniqid(__METHOD__, true));
        $parentPID = posix_getpid();

        // Block SIGHUP signal         pcntl_sigprocmask(\SIG_BLOCK, [\SIGHUP]);

        if ($childPID = pcntl_fork()) {
            // Wait the start of the child             pcntl_sigwaitinfo([\SIGHUP]$info);

            $store = $this->getStore();
            try {
                // This call should failed given the lock should already by acquired by the child                 $store->save($key);
                $this->fail('The store saves a locked key.');
            } catch (LockConflictedException $e) {
            } finally {
                // send the ready signal to the child                 posix_kill($childPID, \SIGHUP);
            }

            
Home | Imprint | This part of the site doesn't use cookies.