/** * turns on getting output and error output from the underlying process. * @return Process * @throws \ Runtimeexception */ public function enableoutput () {// enableOutput if ($this- >isrunning ()) {// if run throw new \runtimeexception (' Enabling output while the process is running is not possible. '); } $this outputdisabled = false;// output Flag bits No return $this;// return class itself } /** * output is disabled * @return bool */ public function isoutputdisabled ()// return whether isOutputDisabled Direct return Current results { return $this outputdisabled; } /** * Gets the current output pipe * @return string * @throws \LogicException * @throws \LogicException * @api */ public function getoutput () Get current output pipe { if ($this->outputdisabled) {// If disable output throw new \logicexception (' output has been disabled. '); / logicexception } $this->requireprocessisstarted (__function__);// get process start $this->readpipes (false, ' \ \ ' === ds ? ! $this processinformation[' running '] : true);// read pipeline information return $this->stdout;// return output information // processinformation } /** * The output returned in an incremental manner. * @return string */ public function getincrementaloutput () {// output results returned incrementally $this->requIreprocessisstarted (__function__);// Start process $data = $this->getoutput ();// get output information $latest = substr ($data, $this->incrementaloutputoffset);// Incremental location if (false === $latest) {// If increment is empty return '; } $this->incrementaloutputoffset = strlen ($data);// Callout Next start position return $latest;// return increment is a string } /** * empty output * @return process */ public function clearoutpUT ()// clear output { $this stdout = ';// total output data $this incrementaloutputoffset = 0;// Increment position initialize to 0 return $this;// return class itself } /** * returns the current error output of process (STDERR). * @return string */ public function geterroroutput () {// get error Output if ($this->outputdisabled) { throw new \logicexception (' output has been Disabled.'); } $this Requireprocessisstarted (__function__);// Start program $this Readpipes (false, ' \ \ ' === ds ? ! $this->processinformation[' running '] : true);// Read pipe information return $this->stderr;// return Error string } /** * return incrementally errorOutput * @return string */ public function getincrementalerroroutput () {// Incremental mode return error message $this->requireprocessisstarted (__function__ ); $data = $this->geterroroutput (); $latest = substr ($data, $this->incrementalerroroutputoffset); if (false === $latest) { return '; } $this->incrementalerroroutputoffset = strlen ($data); return $latest; }// Ibid. General information output /** * emptying errorOutput * @return Process */ public Function clearerroroutput () { $ this->stderr = '; $this->incrementalerroroutputoffset = 0; return $this; }// Clear Error info /** * get exit code * @return null|int */ public function getexitcode () {// get exit codes if ($this->issigchildenabled () && ! $this enhancesigchildcompatibility) { Throw new \runtimeexception (' this php has been compiled with -- Enable-sigchild. you must use setenhancesigchildcompatibility () to use this method. '); }// Get exit Codes $this->updatestatus (FALSE);//Update status return $this->exitcode;// Exit } /** * Get exit Text * @return null|string */ public function getexitcodetext () { if (null === $exitcode = $this->getexitcode ()) { return null; } return isset (self:: $exitCodes [$exitcode]) ? self::$ exitcodes[$exitcode] : ' unknown error '; }// get exit Text tips /** * Check for Success * @return bool */ public function issuccessful () { return 0 === $this->getexitcode (); }// if the normal exit for 0 is successful /** * Whether an uncaught signal has been terminated sub-process * @return bool */ public function hasbeensignaled () { $this->requireprocessisterminated (__function__); if ($this->issigchildenabled ()) { throw new \runtimeexception (' this php has been compiled with --enable-Sigchild. term signal can not be retrieved. '); } $this UpdateStatus (False); return $this->processinformation[' Signaled ']; }
This article is from the "Focus on PHP Group number: 414194301" blog, please be sure to keep this source http://jingshanls.blog.51cto.com/3357095/1886084
[Li Jingshan php] every day tp5-20170123|thinkphp5-process.php-5