diff --git a/inc/inc.ClassConversionServiceExec.php b/inc/inc.ClassConversionServiceExec.php index bf973b6c6..2bf66982d 100644 --- a/inc/inc.ClassConversionServiceExec.php +++ b/inc/inc.ClassConversionServiceExec.php @@ -83,6 +83,7 @@ class SeedDMS_ConversionServiceExec extends SeedDMS_ConversionServiceBase { fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); + if ($timeleft <= 0) { proc_terminate($process); throw new Exception("command timeout after ".$orgtimeout." secs on: " . $cmd); @@ -98,6 +99,10 @@ class SeedDMS_ConversionServiceExec extends SeedDMS_ConversionServiceBase { $this->to = $to; $this->cmd = $cmd; $this->timeout = ((int) $timeout) ? (int) $timeout : 5; + /* Command fails if stderr is not empty */ + $this->failonstderr = true; + /* Command fails if return code is not 0 */ + $this->failonretcode = false; } public function getInfo() { @@ -178,9 +183,17 @@ class SeedDMS_ConversionServiceExec extends SeedDMS_ConversionServiceBase { } if(!empty($ret['stderr'])) { if($this->logger) { - $this->logger->log('Conversion from '.$this->from.' to '.$this->to.' with cmd "'.$this->cmd.'" failed: '.$ret['stderr'], PEAR_LOG_ERR); + $this->logger->log('Conversion from '.$this->from.' to '.$this->to.' with cmd "'.$this->cmd.'" failed: stderr is '.$ret['stderr'], PEAR_LOG_ERR); } - return false; + if ($this->failonstderr) + return false; + } + if(!empty($ret['return'])) { + if($this->logger) { + $this->logger->log('Conversion from '.$this->from.' to '.$this->to.' with cmd "'.$this->cmd.'" failed: Error code '.$ret['return'], PEAR_LOG_ERR); + } + if ($this->failonretcode) + return false; } $end = microtime(true); if($this->logger) {