ensure writing phar files is enabled or respawn with PHP setting which allows writing

@param int $wait
@return void
@uses assertWritable()
969652
public function coerceWritable($wait = 1)
    {
        try {
            $this->assertWritable();
        }
        catch (UnexpectedValueException $e) {
            if (!function_exists('pcntl_exec')) {
                $this->log('<error>' . $e->getMessage() . '</error>');
                return;
            }

            $this->log('<info>' . $e->getMessage() . ', trying to re-spawn with correct config</info>');
            if ($wait) {
                sleep($wait);
            }

            $args = array_merge(array('php', '-d phar.readonly=off'), $_SERVER['argv']);
            if (pcntl_exec('/usr/bin/env', $args) === false) {
                $this->log('<error>Unable to switch into new configuration</error>');
                return;
            }
        }
    }
475124
public function setTimeouts($read, $write)
    {
        parent::setTimeouts($read, $write);
        if ($this->fd !== null) {
            $this->setOption(
                \EventUtil::SOL_SOCKET,
                \EventUtil::SO_SNDTIMEO,
                ['sec' => $this->timeoutWrite, 'usec' => 0]
            );
            $this->setOption(
                \EventUtil::SOL_SOCKET,
                \EventUtil::SO_RCVTIMEO,
                ['sec' => $this->timeoutRead, 'usec' => 0]
            );
        }
    }
98370
private function push(string $data): Awaitable
    {
        $length = strlen($data);
        $delayed = new Delayed();
        \eio_write(
            $this->handle,
            $data,
            $length,
            $this->append ? $this->size : $this->position,
            null,
            function (Delayed $delayed, $result, $req) use ($length) {
                if (-1 === $result) {
                    $delayed->reject(new FileException(
                        sprintf('Writing to the file failed: %s.', \eio_get_last_error($req))
                    ));
                } elseif ($this->queue->isEmpty()) {
                    $delayed->reject(new FileException('No pending write, the file may have been closed.'));
                } else {
                    $this->queue->shift();

                    if ($this->append) {
                        $this->size += $result;
                    } else {
                        $this->position += $result;
                        if ($this->position > $this->size) {
                            $this->size = $this->position;
                        }
                    }

                    $delayed->resolve($result);
                }
            },
            $delayed
        );

        return $delayed;
    }
172417
public function write(string $data): void
	{
		if ($this->connected() === false)
		{
			throw new \Exception('Not connected');
		}

		fwrite($this->connection, $data);
	}
94401
public function wait($terminationCallback = null, $addToCompletedQueue = true)
    {
        $lastProcessesRunningCount = $currentRunningProcessesCount = $this->countRunning();
        while ($currentRunningProcessesCount > 0) {
            $currentRunningProcessesCount = $this->countRunning();
            if ($lastProcessesRunningCount !== $currentRunningProcessesCount) {
                $lastProcessesRunningCount = $currentRunningProcessesCount;
                $this->cleanUP($addToCompletedQueue);
                if (null !== $terminationCallback) {
                    call_user_func($terminationCallback);
                }
            }
            usleep(1000);
        }

        return true;
    }
128875
public function write($data, $cb = null, $offset = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!$this->fd) {
            if ($cb) {
                $cb($this, false);
            }
            return false;
        }
        if ($data === '') {
            if ($cb) {
                $cb($this, 0);
            }
            return false;
        }
        if (!FileSystem::$supported) {
            if ($offset !== null) {
                fseek($data, $offset);
            }
            $r = fwrite($this->fd, $data);
            if ($cb) {
                $cb($this, $r);
            }
            return false;
        }
        if ($cb !== null) {
            $this->onWriteOnce->push($cb);
        }
        $l = mb_orig_strlen($data);
        if ($offset === null) {
            $offset = $this->offset;
            $this->offset += $l;
        }
        $this->writing = true;
        $res = eio_write(
            $this->fd,
            $data,
            $l,
            $offset,
            $pri,
            function ($file, $result) {
                $this->writing = false;
                $this->onWriteOnce->executeAll($file, $result);
            },
            $this
        );
        return $res;
    }
1259282
public function setFileLock($file_lock)
    {
        if (empty($file_lock) && $file_lock !== false) {
            throw new PageCacheException(__CLASS__ . ' file lock can not be empty. To disable set to boolean false.');
        }
        $this->file_lock = $file_lock;
    }
681306
public function activate($wait = true)
    {
        return $this->forge->activateCertificate($this->serverId, $this->siteId, $this->id, $wait);
    }
1331620
public function stop($signal = SIGKILL, $wait = false)
    {
        if ($this->isAlive()) {
            posix_kill($this->_pid, $signal);
            if ($wait) {
                pcntl_waitpid($this->_pid, $status = 0);
            }
        }
    }
418230
private function setWriter($writer = null)
    {
        if ($writer === null) {
            $writer = function ($string) {
                print $string;
            };
        }

        if (!is_callable($writer)) {
            throw new \InvalidArgumentException(
                'Writer must be callable'
            );
        }

        $this->writer = $writer;
    }
751217
public function sendRequest($request, $wait = self::WAIT)
    {
        $this->getSocket()->send($request, ($wait) ? 0 : \ZMQ::MODE_DONTWAIT);
        return $this;
    }
422236
private function waitUntilStopped(int $pid): void
    {
        $wait = 5000; // 5ms
        $timeout = 1000000; // 1 sec
        $elapsed = 0;
        while (posix_getpgid($pid) !== false) {
            usleep($wait);
            $elapsed += $wait;
            if ($elapsed > $timeout) {
                throw new \Exception('Timeout while waiting for PHP-FPM to stop');
            }
        }
    }
1046909
protected function writeStatus($status, $webExecution)
    {
        if ($webExecution)
        {
            $cachedStatus = unserialize(Cache::get('scaffolder-status'));
            array_push($cachedStatus, $status);
            Cache::forever('scaffolder-status', serialize($cachedStatus));
        }
        else
        {
            $this->info($status);
        }
    }
204779
public static function pollEvery(float $wait)
    {
        if (false === strpos((string) $wait, '.')) {
            self::$sleep = (int) $wait;
            self::$usleep = 0;
        } else {
            list($seconds, $hundreds) = explode('.', (string) $wait);
            self::$sleep = (int) $seconds;
            self::$usleep = (int) (((float) sprintf('0.%d', $hundreds)) * 1000000);
        }
    }
961623
public function onWriteOnce($cb)
    {
        if (!$this->writing) {
            $cb($this);
            return;
        }
        $this->onWriteOnce->push($cb);
    }
11107
protected function writePrompt()
    {
        $prompt = $this->parser->apply($this->promptFormatted());

        $this->output->sameLine()->write($prompt);
    }
1155079
public function write($data, $length = self::DEFAULT_LENGTH, $wait = self::DEFAULT_WAIT)
		{
			$bytes = dio_write($this->serial, $data);
			usleep($wait);
			return $bytes;
		}