Hoa central
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Hoa\Console\Processus Class Reference
Inheritance diagram for Hoa\Console\Processus:

Public Member Functions

 __construct ($command, Array $options=null, Array $descriptors=null, $cwd=null, Array $environment=null, $timeout=30)
 
 run ()
 
 eof ($pipe=1)
 
 read ($length, $pipe=1)
 
 readString ($length, $pipe=1)
 
 readCharacter ($pipe=1)
 
 readBoolean ($pipe=1)
 
 readInteger ($length=1, $pipe=1)
 
 readFloat ($length=1, $pipe=1)
 
 readArray ($format=null, $pipe=1)
 
 readLine ($pipe=1)
 
 readAll ($offset=-1, $pipe=1)
 
 scanf ($format, $pipe=1)
 
 write ($string, $length, $pipe=0)
 
 writeString ($string, $pipe=0)
 
 writeCharacter ($char, $pipe=0)
 
 writeBoolean ($boolean, $pipe=0)
 
 writeInteger ($integer, $pipe=0)
 
 writeFloat ($float, $pipe=0)
 
 writeArray (Array $array, $pipe=0)
 
 writeLine ($line, $pipe=0)
 
 writeAll ($string, $pipe=0)
 
 truncate ($size, $pipe=0)
 
 getBasename ()
 
 getDirname ()
 
 getStatus ()
 
 getExitCode ()
 
 isSuccessful ()
 
 terminate ($signal=self::SIGTERM)
 
 getCommand ()
 
 getOptions ()
 
 getCommandLine ()
 
 getCwd ()
 
 getEnvironment ()
 
 setTimeout ($timeout)
 
 getTimeout ()
 
- Public Member Functions inherited from Hoa\Stream\Stream
 __construct ($streamName, $context=null, $wait=false)
 
 open ()
 
 close ()
 
 getStreamName ()
 
 getStreamContext ()
 
 _setStream ($stream)
 
 isOpened ()
 
 setStreamTimeout ($seconds, $microseconds=0)
 
 setStreamBlocking ($mode)
 
 setStreamBuffer ($buffer)
 
 disableStreamBuffer ()
 
 getStreamBufferSize ()
 
 getStreamWrapperName ()
 
 getStreamMetaData ()
 
 isBorrowing ()
 
 on ($listenerId, $callable)
 
 _notify ($ncode, $severity, $message, $code, $transferred, $max)
 
 __toString ()
 
 __destruct ()
 
- Public Member Functions inherited from Hoa\Stream\IStream\In
 eof ()
 
 read ($length)
 
 readString ($length)
 
 readCharacter ()
 
 readBoolean ()
 
 readInteger ($length=1)
 
 readFloat ($length=1)
 
 readArray ($argument=null)
 
 readLine ()
 
 readAll ($offset=0)
 
 scanf ($format)
 
- Public Member Functions inherited from Hoa\Stream\IStream\Out
 write ($string, $length)
 
 writeString ($string)
 
 writeCharacter ($character)
 
 writeBoolean ($boolean)
 
 writeInteger ($integer)
 
 writeFloat ($float)
 
 writeArray (Array $array)
 
 writeLine ($line)
 
 writeAll ($string)
 
 truncate ($size)
 

Static Public Member Functions

static setTitle ($title)
 
static getTitle ()
 
static locate ($binary)
 
static execute ($commandLine, $escape=true)
 
- Static Public Member Functions inherited from Hoa\Stream\Stream
static getStreamHandler ($streamName)
 
static _Hoa_Stream ()
 

Public Attributes

const SIGHUP = 1
 
const SIGINT = 2
 
const SIGQUIT = 3
 
const SIGILL = 4
 
const SIGTRAP = 5
 
const SIGABRT = 6
 
const SIGEMT = 7
 
const SIGFPE = 8
 
const SIGKILL = 9
 
const SIGBUS = 10
 
const SIGSEGV = 11
 
const SIGSYS = 12
 
const SIGPIPE = 13
 
const SIGALRM = 14
 
const SIGTERM = 15
 
const SIGURG = 16
 
const SIGSTOP = 17
 
const SIGTSTP = 18
 
const SIGCONT = 19
 
const SIGCHLD = 20
 
const SIGTTIN = 21
 
const SIGTTOU = 22
 
const SIGIO = 23
 
const SIGXCPU = 24
 
const SIGXFSZ = 25
 
const SIGVTALRM = 26
 
const SIGPROF = 27
 
const SIGWINCH = 28
 
const SIGINFO = 29
 
const SIGUSR1 = 30
 
const SIGUSR2 = 31
 
- Public Attributes inherited from Hoa\Stream\Stream
const NAME = 0
 
const HANDLER = 1
 
const RESOURCE = 2
 
const CONTEXT = 3
 

Protected Member Functions

_open ($streamName, Stream\Context $context=null)
 
 _close ()
 
 getPipe ($pipe)
 
 isPipeSeekable ($pipe)
 
 setCommand ($command)
 
 setOptions (Array $options)
 
 setCwd ($cwd)
 
 setEnvironment (Array $environment)
 
- Protected Member Functions inherited from Hoa\Stream\Stream
_open ($streamName, Context $context=null)
 
 _close ()
 
 getStream ()
 

Protected Attributes

 $_command = null
 
 $_options = []
 
 $_cwd = null
 
 $_environment = null
 
 $_timeout = 30
 
 $_descriptors
 
 $_pipes = null
 
 $_seekable = []
 
- Protected Attributes inherited from Hoa\Stream\Stream
 $_bucket = []
 
 $_bufferSize = 8192
 
 $_streamName = null
 
 $_context = null
 
 $_hasBeenDiffered = false
 
 $_on = null
 
 $_borrowed = false
 

Detailed Description

Class .

Manipulate a processus as a stream.

Definition at line 50 of file Processus.php.

Constructor & Destructor Documentation

Hoa\Console\Processus::__construct (   $command,
Array  $options = null,
Array  $descriptors = null,
  $cwd = null,
Array  $environment = null,
  $timeout = 30 
)

Start a processus.

Parameters
string$commandCommand name.
array$optionsCommand options.
array$descriptorsDescriptors (descriptor => mode —r, w or a—).
string$cwdCurrent working directory.
array$environmentEnvironment.
int$timeoutTimeout.
Returns
void
Exceptions

Definition at line 348 of file Processus.php.

355  {
356  $this->setCommand($command);
357 
358  if (null !== $options) {
359  $this->setOptions($options);
360  }
361 
362  if (null !== $descriptors) {
363  $this->_descriptors = [];
364 
365  foreach ($descriptors as $descriptor => $nature) {
366  if (isset($this->_descriptors[$descriptor])) {
367  throw new Exception(
368  'Pipe descriptor %d already exists, cannot ' .
369  'redefine it.',
370  0,
371  $descriptor
372  );
373  }
374 
375  $this->_descriptors[$descriptor] = $nature;
376  }
377  }
378 
379  $this->setCwd($cwd ?: getcwd());
380 
381  if (null !== $environment) {
382  $this->setEnvironment($environment);
383  }
384 
385  $this->setTimeout($timeout);
386  parent::__construct($this->getCommandLine(), null, true);
387  $this->_on->addIds(['input', 'output', 'timeout', 'start', 'stop']);
388 
389  return;
390  }
setOptions(Array $options)
Definition: Processus.php:982
setEnvironment(Array $environment)
Definition: Processus.php:1054

Here is the call graph for this function:

Member Function Documentation

Hoa\Console\Processus::_close ( )
protected

Close the current stream.

Returns
bool

Definition at line 426 of file Processus.php.

427  {
428  foreach ($this->_pipes as $pipe) {
429  @fclose($pipe);
430  }
431 
432  return @proc_close($this->getStream());
433  }

Here is the call graph for this function:

Here is the caller graph for this function:

& Hoa\Console\Processus::_open (   $streamName,
Stream\Context  $context = null 
)
protected

Open the stream and return the associated resource.

Parameters
string$streamNameStream name (e.g. path or URL).
\Hoa\Stream\Context$contextContext.
Returns
resource
Exceptions

Definition at line 400 of file Processus.php.

401  {
402  $out = @proc_open(
403  $streamName,
404  $this->_descriptors,
405  $this->_pipes,
406  $this->getCwd(),
407  $this->getEnvironment()
408  );
409 
410  if (false === $out) {
411  throw new Exception(
412  'Something wrong happen when running %s.',
413  1,
414  $streamName
415  );
416  }
417 
418  return $out;
419  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Console\Processus::eof (   $pipe = 1)

Test for end-of-file.

Parameters
int$pipePipe descriptor.
Returns
bool

Definition at line 603 of file Processus.php.

604  {
605  return feof($this->getPipe($pipe));
606  }

Here is the call graph for this function:

static Hoa\Console\Processus::execute (   $commandLine,
  $escape = true 
)
static

Quick process execution. Returns only the STDOUT.

Parameters
string$commandLineCommand line to execute.
bool$escapeEscape command.
Returns
string

Definition at line 1165 of file Processus.php.

1166  {
1167  if (true === $escape) {
1168  $commandLine = escapeshellcmd($commandLine);
1169  }
1170 
1171  return rtrim(shell_exec($commandLine));
1172  }

Here is the caller graph for this function:

Hoa\Console\Processus::getBasename ( )

Get filename component of path.

Returns
string

Implements Hoa\Stream\IStream\Pathable.

Definition at line 892 of file Processus.php.

893  {
894  return basename($this->getCommand());
895  }

Here is the call graph for this function:

Hoa\Console\Processus::getCommand ( )

Get command name.

Returns
string

Definition at line 971 of file Processus.php.

972  {
973  return $this->_command;
974  }

Here is the caller graph for this function:

Hoa\Console\Processus::getCommandLine ( )

Get command-line.

Returns
string

Definition at line 1009 of file Processus.php.

1010  {
1011  $out = $this->getCommand();
1012 
1013  foreach ($this->getOptions() as $key => $value) {
1014  if (!is_int($key)) {
1015  $out .= ' ' . $key . '=' . $value;
1016  } else {
1017  $out .= ' ' . $value;
1018  }
1019  }
1020 
1021  return $out;
1022  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Console\Processus::getCwd ( )

Get current working directory of the process.

Returns
string

Definition at line 1043 of file Processus.php.

1044  {
1045  return $this->_cwd;
1046  }

Here is the caller graph for this function:

Hoa\Console\Processus::getDirname ( )

Get directory name component of path.

Returns
string

Implements Hoa\Stream\IStream\Pathable.

Definition at line 902 of file Processus.php.

903  {
904  return dirname($this->getCommand());
905  }

Here is the call graph for this function:

Hoa\Console\Processus::getEnvironment ( )

Get environment of the process.

Returns
array

Definition at line 1067 of file Processus.php.

1068  {
1069  return $this->_environment;
1070  }

Here is the caller graph for this function:

Hoa\Console\Processus::getExitCode ( )

Get exit code (alias of $this->getStatus()['exitcode']);

Returns
int

Definition at line 922 of file Processus.php.

923  {
924  $handle = $this->getStatus();
925 
926  return $handle['exitcode'];
927  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Console\Processus::getOptions ( )

Get options.

Returns
array

Definition at line 999 of file Processus.php.

1000  {
1001  return $this->_options;
1002  }

Here is the caller graph for this function:

Hoa\Console\Processus::getPipe (   $pipe)
protected

Get pipe resource.

Parameters
int$pipePipe descriptor.
Returns
resource
Exceptions

Definition at line 567 of file Processus.php.

568  {
569  if (!isset($this->_pipes[$pipe])) {
570  throw new Exception(
571  'Pipe descriptor %d does not exist, cannot read from it.',
572  2,
573  $pipe
574  );
575  }
576 
577  return $this->_pipes[$pipe];
578  }

Here is the caller graph for this function:

Hoa\Console\Processus::getStatus ( )

Get status.

Returns
array

Definition at line 912 of file Processus.php.

913  {
914  return proc_get_status($this->getStream());
915  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Console\Processus::getTimeout ( )

Get timeout of the process.

Returns
int

Definition at line 1091 of file Processus.php.

1092  {
1093  return $this->_timeout;
1094  }

Here is the caller graph for this function:

static Hoa\Console\Processus::getTitle ( )
static

Get process title.

Returns
string

Definition at line 1118 of file Processus.php.

1119  {
1120  if (PHP_VERSION_ID < 50500) {
1121  return null;
1122  }
1123 
1124  return cli_get_process_title();
1125  }
Hoa\Console\Processus::isPipeSeekable (   $pipe)
protected

Check if a pipe is seekable or not.

Parameters
int$pipePipe descriptor.
Returns
bool

Definition at line 586 of file Processus.php.

587  {
588  if (!isset($this->_seekable[$pipe])) {
589  $_pipe = $this->getPipe($pipe);
590  $data = stream_get_meta_data($_pipe);
591  $this->_seekable[$pipe] = $data['seekable'];
592  }
593 
594  return $this->_seekable[$pipe];
595  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Console\Processus::isSuccessful ( )

Whether the processus have ended successfully.

Returns
boolean

Definition at line 934 of file Processus.php.

935  {
936  return 0 === $this->getExitCode();
937  }

Here is the call graph for this function:

static Hoa\Console\Processus::locate (   $binary)
static

Found the place of a binary.

Parameters
string$binaryBinary.
Returns
string

Definition at line 1133 of file Processus.php.

1134  {
1135  if (isset($_ENV['PATH'])) {
1136  $separator = ':';
1137  $path = &$_ENV['PATH'];
1138  } elseif (isset($_SERVER['PATH'])) {
1139  $separator = ':';
1140  $path = &$_SERVER['PATH'];
1141  } elseif (isset($_SERVER['Path'])) {
1142  $separator = ';';
1143  $path = &$_SERVER['Path'];
1144  } else {
1145  return null;
1146  }
1147 
1148  foreach (explode($separator, $path) as $directory) {
1149  if (true === file_exists($out = $directory . DS . $binary)) {
1150  return $out;
1151  }
1152  }
1153 
1154  return null;
1155  }

Here is the caller graph for this function:

Hoa\Console\Processus::read (   $length,
  $pipe = 1 
)

Read n characters.

Parameters
int$lengthLength.
int$pipePipe descriptor.
Returns
string
Exceptions

Definition at line 616 of file Processus.php.

617  {
618  if (0 > $length) {
619  throw new Exception(
620  'Length must be greater than 0, given %d.',
621  3,
622  $length
623  );
624  }
625 
626  return fread($this->getPipe($pipe), $length);
627  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Console\Processus::readAll (   $offset = -1,
  $pipe = 1 
)

Read all, i.e. read as much as possible.

Parameters
int$offsetOffset.
int$pipePipe descriptor.
Returns
string

Definition at line 718 of file Processus.php.

719  {
720  $_pipe = $this->getPipe($pipe);
721 
722  if (true === $this->isPipeSeekable($pipe)) {
723  $offset += ftell($_pipe);
724  } else {
725  $offset = -1;
726  }
727 
728  return stream_get_contents($_pipe, -1, $offset);
729  }

Here is the call graph for this function:

Hoa\Console\Processus::readArray (   $format = null,
  $pipe = 1 
)

Read an array. Alias of the $this->scanf() method.

Parameters
string$formatFormat (see printf's formats).
int$pipePipe descriptor.
Returns
array

Definition at line 695 of file Processus.php.

696  {
697  return $this->scanf($format, $pipe);
698  }
scanf($format, $pipe=1)
Definition: Processus.php:738

Here is the call graph for this function:

Hoa\Console\Processus::readBoolean (   $pipe = 1)

Read a boolean.

Parameters
int$pipePipe descriptor.
Returns
bool

Definition at line 658 of file Processus.php.

659  {
660  return (bool) $this->read(1, $pipe);
661  }
read($length, $pipe=1)
Definition: Processus.php:616

Here is the call graph for this function:

Hoa\Console\Processus::readCharacter (   $pipe = 1)

Read a character.

Parameters
int$pipePipe descriptor.
Returns
string

Definition at line 647 of file Processus.php.

648  {
649  return fgetc($this->getPipe($pipe));
650  }

Here is the call graph for this function:

Hoa\Console\Processus::readFloat (   $length = 1,
  $pipe = 1 
)

Read a float.

Parameters
int$lengthLength.
int$pipePipe descriptor.
Returns
float

Definition at line 682 of file Processus.php.

683  {
684  return (float) $this->read($length, $pipe);
685  }
read($length, $pipe=1)
Definition: Processus.php:616

Here is the call graph for this function:

Hoa\Console\Processus::readInteger (   $length = 1,
  $pipe = 1 
)

Read an integer.

Parameters
int$lengthLength.
int$pipePipe descriptor.
Returns
int

Definition at line 670 of file Processus.php.

671  {
672  return (int) $this->read($length, $pipe);
673  }
read($length, $pipe=1)
Definition: Processus.php:616

Here is the call graph for this function:

Hoa\Console\Processus::readLine (   $pipe = 1)

Read a line.

Parameters
int$pipePipe descriptor.
Returns
string

Definition at line 706 of file Processus.php.

707  {
708  return stream_get_line($this->getPipe($pipe), 1 << 15, "\n");
709  }

Here is the call graph for this function:

Hoa\Console\Processus::readString (   $length,
  $pipe = 1 
)

Alias of $this->read().

Parameters
int$lengthLength.
int$pipePipe descriptor.
Returns
string

Definition at line 636 of file Processus.php.

637  {
638  return $this->read($length, $pipe);
639  }
read($length, $pipe=1)
Definition: Processus.php:616

Here is the call graph for this function:

Hoa\Console\Processus::run ( )

Run the process and fire events (amongst start, stop, input, output and timeout). If an event returns false, it will close the current pipe. For a simple run without firing events, use the $this->open() method.

Returns
void

Definition at line 443 of file Processus.php.

444  {
445  if (false === $this->isOpened()) {
446  $this->open();
447  } else {
448  $this->_close();
449  $this->_setStream($this->_open(
450  $this->getStreamName(),
451  $this->getStreamContext()
452  ));
453  }
454 
455  $this->_on->fire('start', new Core\Event\Bucket());
456 
457  $_read = [];
458  $_write = [];
459  $_except = [];
460 
461  foreach ($this->_pipes as $p => $pipe) {
462  switch ($this->_descriptors[$p][1]) {
463  case 'r':
464  stream_set_blocking($pipe, false);
465  $_write[] = $pipe;
466 
467  break;
468 
469  case 'w':
470  case 'a':
471  stream_set_blocking($pipe, true);
472  $_read[] = $pipe;
473 
474  break;
475  }
476  }
477 
478  while (true) {
479  foreach ($_read as $i => $r) {
480  if (false === is_resource($r)) {
481  unset($_read[$i]);
482  }
483  }
484 
485  foreach ($_write as $i => $w) {
486  if (false === is_resource($w)) {
487  unset($_write[$i]);
488  }
489  }
490 
491  foreach ($_except as $i => $e) {
492  if (false === is_resource($e)) {
493  unset($_except[$i]);
494  }
495  }
496 
497  if (empty($_read) && empty($_write) && empty($_except)) {
498  break;
499  }
500 
501  $read = $_read;
502  $write = $_write;
503  $except = $_except;
504  $select = stream_select($read, $write, $except, $this->getTimeout());
505 
506  if (0 === $select) {
507  $this->_on->fire('timeout', new Core\Event\Bucket());
508 
509  break;
510  }
511 
512  foreach ($read as $i => $_r) {
513  $pipe = array_search($_r, $this->_pipes);
514  $line = $this->readLine($pipe);
515 
516  if (false === $line) {
517  $result = [false];
518  } else {
519  $result = $this->_on->fire(
520  'output',
521  new Core\Event\Bucket([
522  'pipe' => $pipe,
523  'line' => $line
524  ])
525  );
526  }
527 
528  if (true === feof($_r) || in_array(false, $result, true)) {
529  fclose($_r);
530  unset($_read[$i]);
531 
532  break;
533  }
534  }
535 
536  foreach ($write as $j => $_w) {
537  $result = $this->_on->fire(
538  'input',
539  new Core\Event\Bucket([
540  'pipe' => array_search($_w, $this->_pipes)
541  ])
542  );
543 
544  if (true === feof($_w) || in_array(false, $result, true)) {
545  fclose($_w);
546  unset($_write[$j]);
547  }
548  }
549 
550  if (empty($_read)) {
551  break;
552  }
553  }
554 
555  $this->_on->fire('stop', new Core\Event\Bucket());
556 
557  return;
558  }
_setStream($stream)
Definition: Stream.php:399
& _open($streamName, Stream\Context $context=null)
Definition: Processus.php:400

Here is the call graph for this function:

Hoa\Console\Processus::scanf (   $format,
  $pipe = 1 
)

Parse input from a stream according to a format.

Parameters
string$formatFormat (see printf's formats).
int$pipePipe descriptor.
Returns
array

Definition at line 738 of file Processus.php.

739  {
740  return fscanf($this->getPipe($pipe), $format);
741  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Console\Processus::setCommand (   $command)
protected

Set command name.

Parameters
string$commandCommand name.
Returns
string

Definition at line 958 of file Processus.php.

959  {
960  $old = $this->_command;
961  $this->_command = escapeshellcmd($command);
962 
963  return $old;
964  }

Here is the caller graph for this function:

Hoa\Console\Processus::setCwd (   $cwd)
protected

Set current working directory of the process.

Parameters
string$cwdCurrent working directory.
Returns
string

Definition at line 1030 of file Processus.php.

1031  {
1032  $old = $this->_cwd;
1033  $this->_cwd = $cwd;
1034 
1035  return $old;
1036  }

Here is the caller graph for this function:

Hoa\Console\Processus::setEnvironment ( Array  $environment)
protected

Set environment of the process.

Parameters
array$environmentEnvironment.
Returns
array

Definition at line 1054 of file Processus.php.

1055  {
1056  $old = $this->_environment;
1057  $this->_environment = $environment;
1058 
1059  return $old;
1060  }

Here is the caller graph for this function:

Hoa\Console\Processus::setOptions ( Array  $options)
protected

Set command options.

Parameters
array$optionsOptions (option => value, or input).
Returns
array

Definition at line 982 of file Processus.php.

983  {
984  foreach ($options as &$option) {
985  $option = escapeshellarg($option);
986  }
987 
988  $old = $this->_options;
989  $this->_options = $options;
990 
991  return $old;
992  }

Here is the caller graph for this function:

Hoa\Console\Processus::setTimeout (   $timeout)

Set timeout of the process.

Parameters
int$timeoutTimeout.
Returns
int

Definition at line 1078 of file Processus.php.

1079  {
1080  $old = $this->_timeout;
1081  $this->_timeout = $timeout;
1082 
1083  return $old;
1084  }

Here is the caller graph for this function:

static Hoa\Console\Processus::setTitle (   $title)
static

Set process title.

Parameters
string$titleTitle.
Returns
void

Definition at line 1102 of file Processus.php.

1103  {
1104  if (PHP_VERSION_ID < 50500) {
1105  return;
1106  }
1107 
1108  cli_set_process_title($title);
1109 
1110  return;
1111  }
Hoa\Console\Processus::terminate (   $signal = self::SIGTERM)

Terminate the process.

Parameters
int$signalSignal, amongst self::SIGHUP, SIGINT, SIGQUIT, SIGABRT, SIGKILL, SIGALRM and SIGTERM. Default is self::SIGTERM.
Returns
bool

Definition at line 947 of file Processus.php.

948  {
949  return proc_terminate($this->getStream(), $signal);
950  }

Here is the call graph for this function:

Hoa\Console\Processus::truncate (   $size,
  $pipe = 0 
)

Truncate a file to a given length.

Parameters
int$sizeSize.
int$pipePipe descriptor.
Returns
bool

Definition at line 882 of file Processus.php.

883  {
884  return ftruncate($this->getPipe($pipe), $size);
885  }

Here is the call graph for this function:

Hoa\Console\Processus::write (   $string,
  $length,
  $pipe = 0 
)

Write n characters.

Parameters
string$stringString.
int$lengthLength.
int$pipePipe descriptor.
Returns
mixed
Exceptions

Definition at line 752 of file Processus.php.

753  {
754  if (0 > $length) {
755  throw new Exception(
756  'Length must be greater than 0, given %d.',
757  4,
758  $length
759  );
760  }
761 
762  return fwrite($this->getPipe($pipe), $string, $length);
763  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Console\Processus::writeAll (   $string,
  $pipe = 0 
)

Write all, i.e. as much as possible.

Parameters
string$stringString.
int$pipePipe descriptor.
Returns
mixed

Definition at line 870 of file Processus.php.

871  {
872  return $this->write($string, strlen($string), $pipe);
873  }
write($string, $length, $pipe=0)
Definition: Processus.php:752

Here is the call graph for this function:

Hoa\Console\Processus::writeArray ( Array  $array,
  $pipe = 0 
)

Write an array.

Parameters
array$arrayArray.
int$pipePipe descriptor.
Returns
mixed

Definition at line 838 of file Processus.php.

839  {
840  $array = var_export($array, true);
841 
842  return $this->write($array, strlen($array), $pipe);
843  }
write($string, $length, $pipe=0)
Definition: Processus.php:752

Here is the call graph for this function:

Hoa\Console\Processus::writeBoolean (   $boolean,
  $pipe = 0 
)

Write a boolean.

Parameters
bool$booleanBoolean.
int$pipePipe descriptor.
Returns
mixed

Definition at line 798 of file Processus.php.

799  {
800  return $this->write((string) (bool) $boolean, 1, $pipe);
801  }
write($string, $length, $pipe=0)
Definition: Processus.php:752

Here is the call graph for this function:

Hoa\Console\Processus::writeCharacter (   $char,
  $pipe = 0 
)

Write a character.

Parameters
string$charCharacter.
int$pipePipe descriptor.
Returns
mixed

Definition at line 786 of file Processus.php.

787  {
788  return $this->write((string) $char[0], 1, $pipe);
789  }
write($string, $length, $pipe=0)
Definition: Processus.php:752

Here is the call graph for this function:

Hoa\Console\Processus::writeFloat (   $float,
  $pipe = 0 
)

Write a float.

Parameters
float$floatFloat.
int$pipePipe descriptor.
Returns
mixed

Definition at line 824 of file Processus.php.

825  {
826  $float = (string) (float) $float;
827 
828  return $this->write($float, strlen($float), $pipe);
829  }
write($string, $length, $pipe=0)
Definition: Processus.php:752

Here is the call graph for this function:

Hoa\Console\Processus::writeInteger (   $integer,
  $pipe = 0 
)

Write an integer.

Parameters
int$integerInteger.
int$pipePipe descriptor.
Returns
mixed

Definition at line 810 of file Processus.php.

811  {
812  $integer = (string) (int) $integer;
813 
814  return $this->write($integer, strlen($integer), $pipe);
815  }
write($string, $length, $pipe=0)
Definition: Processus.php:752

Here is the call graph for this function:

Hoa\Console\Processus::writeLine (   $line,
  $pipe = 0 
)

Write a line.

Parameters
string$lineLine.
int$pipePipe descriptor.
Returns
mixed

Definition at line 852 of file Processus.php.

853  {
854  if (false === $n = strpos($line, "\n")) {
855  return $this->write($line . "\n", strlen($line) + 1, $pipe);
856  }
857 
858  ++$n;
859 
860  return $this->write(substr($line, 0, $n), $n, $pipe);
861  }
write($string, $length, $pipe=0)
Definition: Processus.php:752

Here is the call graph for this function:

Hoa\Console\Processus::writeString (   $string,
  $pipe = 0 
)

Write a string.

Parameters
string$stringString.
int$pipePipe descriptor.
Returns
mixed

Definition at line 772 of file Processus.php.

773  {
774  $string = (string) $string;
775 
776  return $this->write($string, strlen($string), $pipe);
777  }
write($string, $length, $pipe=0)
Definition: Processus.php:752

Here is the call graph for this function:

Member Data Documentation

Hoa\Console\Processus::$_command = null
protected

Definition at line 278 of file Processus.php.

Hoa\Console\Processus::$_cwd = null
protected

Definition at line 292 of file Processus.php.

Hoa\Console\Processus::$_descriptors
protected
Initial value:
= [
0 => ['pipe', 'r']

Definition at line 313 of file Processus.php.

Hoa\Console\Processus::$_environment = null
protected

Definition at line 299 of file Processus.php.

Hoa\Console\Processus::$_options = []
protected

Definition at line 285 of file Processus.php.

Hoa\Console\Processus::$_pipes = null
protected

Definition at line 324 of file Processus.php.

Hoa\Console\Processus::$_seekable = []
protected

Definition at line 331 of file Processus.php.

Hoa\Console\Processus::$_timeout = 30
protected

Definition at line 306 of file Processus.php.

const Hoa\Console\Processus::SIGABRT = 6

Signal: abort program, formerly SIGIOT (create core image).

int

Definition at line 96 of file Processus.php.

const Hoa\Console\Processus::SIGALRM = 14

Signal: real-time timer expired (terminate process).

int

Definition at line 152 of file Processus.php.

const Hoa\Console\Processus::SIGBUS = 10

Signal: bus error.

int

Definition at line 124 of file Processus.php.

const Hoa\Console\Processus::SIGCHLD = 20

Signal: child status has changed (discard signal).

int

Definition at line 194 of file Processus.php.

const Hoa\Console\Processus::SIGCONT = 19

Signal: continue after stop (discard signal).

int

Definition at line 187 of file Processus.php.

const Hoa\Console\Processus::SIGEMT = 7

Signal: emulate instruction executed (create core image).

int

Definition at line 103 of file Processus.php.

const Hoa\Console\Processus::SIGFPE = 8

Signal: floating-point exception (create core image).

int

Definition at line 110 of file Processus.php.

const Hoa\Console\Processus::SIGHUP = 1

Signal: terminal line hangup (terminate process).

int

Definition at line 61 of file Processus.php.

const Hoa\Console\Processus::SIGILL = 4

Signal: illegal instruction (create core image).

int

Definition at line 82 of file Processus.php.

const Hoa\Console\Processus::SIGINFO = 29

Signal: status request from keyboard (discard signal).

int

Definition at line 257 of file Processus.php.

const Hoa\Console\Processus::SIGINT = 2

Signal: interrupt program (terminate process).

int

Definition at line 68 of file Processus.php.

const Hoa\Console\Processus::SIGIO = 23

Signal: I/O is possible on a descriptor, see fcntl(2) (discard signal).

int

Definition at line 215 of file Processus.php.

const Hoa\Console\Processus::SIGKILL = 9

Signal: kill program (terminate process).

int

Definition at line 117 of file Processus.php.

const Hoa\Console\Processus::SIGPIPE = 13

Signal: write on a pipe with no reader (terminate process).

int

Definition at line 145 of file Processus.php.

const Hoa\Console\Processus::SIGPROF = 27

Signal: profiling timer alarm, see setitimer(2) (terminate process).

int

Definition at line 243 of file Processus.php.

const Hoa\Console\Processus::SIGQUIT = 3

Signal: quit program (create core image).

int

Definition at line 75 of file Processus.php.

const Hoa\Console\Processus::SIGSEGV = 11

Signal: segmentation violation (create core image).

int

Definition at line 131 of file Processus.php.

const Hoa\Console\Processus::SIGSTOP = 17

Signal: stop, cannot be caught or ignored (stop proces).

int

Definition at line 173 of file Processus.php.

const Hoa\Console\Processus::SIGSYS = 12

Signal: non-existent system call invoked (create core image).

int

Definition at line 138 of file Processus.php.

const Hoa\Console\Processus::SIGTERM = 15

Signal: software termination signal (terminate process).

int

Definition at line 159 of file Processus.php.

const Hoa\Console\Processus::SIGTRAP = 5

Signal: trace trap (create core image).

int

Definition at line 89 of file Processus.php.

const Hoa\Console\Processus::SIGTSTP = 18

Signal: stop signal generated from keyboard (stop process).

int

Definition at line 180 of file Processus.php.

const Hoa\Console\Processus::SIGTTIN = 21

Signal: background read attempted from control terminal (stop process).

int

Definition at line 201 of file Processus.php.

const Hoa\Console\Processus::SIGTTOU = 22

Signal: background write attempted to control terminal (stop process).

int

Definition at line 208 of file Processus.php.

const Hoa\Console\Processus::SIGURG = 16

Signal: urgent condition present on socket (discard signal).

int

Definition at line 166 of file Processus.php.

const Hoa\Console\Processus::SIGUSR1 = 30

Signal: User defined signal 1 (terminate process).

int

Definition at line 264 of file Processus.php.

const Hoa\Console\Processus::SIGUSR2 = 31

Signal: User defined signal 2 (terminate process).

int

Definition at line 271 of file Processus.php.

const Hoa\Console\Processus::SIGVTALRM = 26

Signal: virtual time alarm, see setitimer(2) (terminate process).

int

Definition at line 236 of file Processus.php.

const Hoa\Console\Processus::SIGWINCH = 28

Signal: Window size change (discard signal).

int

Definition at line 250 of file Processus.php.

const Hoa\Console\Processus::SIGXCPU = 24

Signal: cpu time limit exceeded, see setrlimit(2) (terminate process).

int

Definition at line 222 of file Processus.php.

const Hoa\Console\Processus::SIGXFSZ = 25

Signal: file size limit exceeded, see setrlimit(2) (terminate process).

int

Definition at line 229 of file Processus.php.


The documentation for this class was generated from the following file: