diff --git a/include/util/cnvrtFunctions.php b/include/util/cnvrtFunctions.php index 80efa19a..3b5378f8 100644 --- a/include/util/cnvrtFunctions.php +++ b/include/util/cnvrtFunctions.php @@ -66,11 +66,10 @@ function CnvrtFileExec($src, $timeOut = CNVRT_TIMEOUT) { /* * Funcoes do servico. */ - function CnvrtMonitor($src, $dst, $cnvrtType, $timeOut = 3) { $result = false; $timeSend = 0; - $sleepTime = 1000; + $sleepTime = 1000; // loop usleep 0,001 $filename = time(); $sendName = sprintf('%s_%s.snd', CNVRT_BASE, $filename); $procName = sprintf('%s_%s.prc', CNVRT_BASE, $filename); @@ -179,13 +178,27 @@ function CnvrtLog($log) { } function CnvrtKillProcess($procName, $src, $killProc = true) { - $pidFile = sprintf("%s.pid", $procName); - if ($killProc) { - exec(sprintf("kill -9 %s", file_get_contents($pidFile))); - exec(sprintf("kill -9 %s", CnvrtProcessId('ffmpeg', $src))); + $pidFile = sprintf( "%s.pid", $procName ); + if ( $killProc ) { + + /* Esse arquivo é gerado pelo daemon cnvrt */ + $pidFile_content = file_get_contents( $pidFile ); + if( $pidFile_content !== false ){ + exec( sprintf("kill -9 %s", $pidFile_content) ); + } + else{ // Envia log, não foi possível usar cnvrt + CnvrtLog( "Não foi possivel obter o pid em $pidFile" ); + } + + + $pid = CnvrtProcessId( 'ffmpeg', $src ); + if($pid != 0){ // Diferente de zero, o zero terminará o processo PHP + exec( sprintf( "kill -9 %s", $pid )); + } } - unlink($procName); - unlink($pidFile); + + unlink( $procName ); + unlink( $pidFile ); } function CnvrtProcessId($process, $srcId) {