public function Process::__construct

Constructor.

@api

Parameters

string $commandline The command line to run:

string $cwd The working directory:

array $env The environment variables or null to inherit:

string $stdin The STDIN content:

integer $timeout The timeout in seconds:

array $options An array of options for proc_open:

Throws

RuntimeException When proc_open is not installed

1 call to Process::__construct()
PhpProcess::__construct in drupal/core/vendor/symfony/process/Symfony/Component/Process/PhpProcess.php
Constructor.
1 method overrides Process::__construct()
PhpProcess::__construct in drupal/core/vendor/symfony/process/Symfony/Component/Process/PhpProcess.php
Constructor.

File

drupal/core/vendor/symfony/process/Symfony/Component/Process/Process.php, line 132

Class

Process
Process is a thin wrapper around proc_* functions to ease start independent PHP processes.

Namespace

Symfony\Component\Process

Code

public function __construct($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) {
  if (!function_exists('proc_open')) {
    throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
  }
  $this->commandline = $commandline;
  $this->cwd = $cwd;

  // on windows, if the cwd changed via chdir(), proc_open defaults to the dir where php was started
  // on gnu/linux, PHP builds with --enable-maintainer-zts are also affected
  // @see : https://bugs.php.net/bug.php?id=51800
  // @see : https://bugs.php.net/bug.php?id=50524
  if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || defined('PHP_WINDOWS_VERSION_BUILD'))) {
    $this->cwd = getcwd();
  }
  if (null !== $env) {
    $this->env = array();
    foreach ($env as $key => $value) {
      $this->env[(string) $key] = (string) $value;
    }
  }
  else {
    $this->env = null;
  }
  $this->stdin = $stdin;
  $this
    ->setTimeout($timeout);
  $this->enhanceWindowsCompatibility = true;
  $this->enhanceSigchildCompatibility = !defined('PHP_WINDOWS_VERSION_BUILD') && $this
    ->isSigchildEnabled();
  $this->options = array_replace(array(
    'suppress_errors' => true,
    'binary_pipes' => true,
  ), $options);
}