diff --git a/web/zm.php b/web/zm.php index 1691555d4..ba492f0c0 100644 --- a/web/zm.php +++ b/web/zm.php @@ -125,15 +125,29 @@ if ( $action ) $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zmc $did' | grep -v grep" ) ); if ( $ps_array[3] ) { - $zmc = $ps_array[3]; - exec( "kill -TERM $zmc" ); + $zmc_pid = $ps_array[3]; + exec( "kill -TERM $zmc_pid" ); + } + while( $zmc_pid ) + { + sleep( 1 ); + $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zmc $did' | grep -v grep" ) ); + $zmc_pid = $ps_array[3]; } } elseif ( !$zmc_status && $zmc_action ) { # Start Capture daemon - $command = "/usr/local/bin/zmc $did &"; + $command = '/usr/local/bin/zmc '.$did.' 2>/dev/null >&- <&- >/dev/null &'; exec( $command ); + $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zmc $did' | grep -v grep" ) ); + $zmc_pid = $ps_array[3]; + while ( !$zmc_pid ) + { + sleep( 1 ); + $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zmc $did' | grep -v grep" ) ); + $zmc_pid = $ps_array[3]; + } } if ( $zma_status && !$zma_action ) { @@ -141,17 +155,30 @@ if ( $action ) $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zma $did' | grep -v grep" ) ); if ( $ps_array[3] ) { - $zma = $ps_array[3]; - exec( "kill -TERM $zma" ); + $zma_pid = $ps_array[3]; + exec( "kill -TERM $zma_pid" ); + } + while( $zma_pid ) + { + sleep( 1 ); + $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zma $did' | grep -v grep" ) ); + $zma_pid = $ps_array[3]; } } elseif ( !$zma_status && $zma_action ) { # Start Analysis daemon - $command = "/usr/local/bin/zma $did &"; + $command = '/usr/local/bin/zma '.$did.' 2>/dev/null >&- <&- >/dev/null &'; exec( $command ); + $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zma $did' | grep -v grep" ) ); + $zma_pid = $ps_array[3]; + while ( !$zma_pid ) + { + sleep( 1 ); + $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zma $did' | grep -v grep" ) ); + $zma_pid = $ps_array[3]; + } } - sleep( 3 ); } } @@ -162,7 +189,7 @@ if ( !$view ) if ( $view == "console" ) { - header("Refresh: ".REFRESH_MAIN."; URL='index.php" ); + header("Refresh: ".REFRESH_MAIN."; URL='$PHP_SELF'" ); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 @@ -227,14 +254,14 @@ function newWindow(Url,Name,Width,Height) {