Mercurial > epgrec.yaz
changeset 166:68f6b36e7c01
mod: ¥Ç¥Ð¥Ã¥°¥Ð¡¼¥¸¥ç¥ó
author | Sushi-k <[email protected]> |
---|---|
date | Fri, 16 Apr 2010 17:31:18 +0900 |
parents | 254d8a21bf36 |
children | b307e3749e80 |
files | recorder.php |
diffstat | 1 files changed, 32 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/recorder.php Tue Apr 06 11:03:45 2010 +0900 +++ b/recorder.php Fri Apr 16 17:31:18 2010 +0900 @@ -8,6 +8,8 @@ include_once( INSTALL_PATH . "/recLog.inc.php" ); include_once( INSTALL_PATH . "/reclib.php" ); +define("DEBUG", true ); + // å¾æ¹äºææ§ if( ! defined( RECORDER_CMD ) ) { @@ -19,6 +21,7 @@ $msgh_r = null; // åä¿¡ç¨ã¡ãã»ã¼ã¸ãã³ãã© $msgh_w = null; // éä¿¡ç¨ã¡ãã»ã¼ã¸ãã³ãã© +$logfile = INSTALL_PATH."/settings/recorder_".$reserve_id.".log"; // ãã³ããããã³ã°ã¡ãã»ã¼ã¸åä¿¡ @@ -68,7 +71,7 @@ 2 => array( 'file','/dev/null','w' ), ); - $ps = proc_open( "/bin/ps -o pid,ppid -ax" , $d, $pipes ); + $ps = proc_open( "/bin/ps -o pid,ppid ax" , $d, $pipes ); do { $st = proc_get_status( $ps ); }while( $st['running'] ); @@ -92,24 +95,48 @@ function epgrec_termproc( $p ) { + if( DEBUG ) { + global $logfile; + system( "ps ax >>".$logfile ); + system( "echo ------- >>".$logfile ); + } + $cpids = epgrec_childproc( $p ); + if( DEBUG ) { + global $logfile; + + foreach( $cpids as $cpid ) { + system( "echo ".$cpid." >>".$logfile ); + } + system( "echo ------- >>".$logfile ); + } + @proc_terminate( $p ); sleep(1); @proc_terminate( $p ); // 2度éã foreach( $cpids as $cpid ) { - @posix_kill( $cpid, SIGTERM ); // sigterm - usleep(100); - @posix_kill( $cpid, SIGKILL ); // sigkill + $ret = posix_kill( $cpid, SIGTERM ); // sigterm + usleep(100*1000); + if( ! $ret ) posix_kill( $cpid, SIGKILL ); // sigkill } + if( DEBUG ) { + global $logfile; + system( "ps ax >>".$logfile ); + system( "echo ------- >>".$logfile ); + } + + foreach( $cpids as $cpid ) { + $ret = posix_kill( $cpid, SIGTERM ); // sigterm + if( $ret ) return false; // æããããã»ã¹ãåå¨ããã®ã§ã¨ã©ã¼ + } return true; // ä¿è¨¼ã§ããªã } ////// ããããæ¬ç·¨ - // ã¡ãã»ã¼ã¸ãã³ãã©ãå¾ã $ipc_key = ftok( RECORDER_CMD, "R" ); $msgh_r = msg_get_queue( $ipc_key );