LimeShellProcess.php 765 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. class LimeShellProcess extends LimeShellCommand
  3. {
  4. protected
  5. $handle = null,
  6. $errorHandle = null;
  7. public function execute()
  8. {
  9. $this->errorHandle = fopen($this->errorFile, 'w+'); // clear error file
  10. $this->handle = popen($this->command, 'r');
  11. }
  12. public function getStatus()
  13. {
  14. throw new BadMethodCallException('Status is not supported by processes');
  15. }
  16. public function getOutput()
  17. {
  18. return feof($this->handle) ? '' : fread($this->handle, 1024);
  19. }
  20. public function getErrors()
  21. {
  22. // don't check feof here, for some reason some errors get dropped then
  23. return fread($this->errorHandle, 1024);
  24. }
  25. public function isClosed()
  26. {
  27. return feof($this->handle) && feof($this->errorHandle);
  28. }
  29. }