Commit ebaeff33 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev
Browse files

cmd=status will not hang

parent c152627e
Loading
Loading
Loading
Loading
+32 −10
Original line number Diff line number Diff line
@@ -129,6 +129,24 @@ if ($cmd == "run_camogm")
}
else if ($cmd == "status")
{
	// is camogm running
	$camogm_running = "not running";
	
	exec('ps | grep "camogm"', $arr);
	function low_daemon($v)
	{
		return (substr($v, -1) != ']');
	}
	
	$p = (array_filter($arr, "low_daemon"));
	$check = implode("<br />",$p);
	
	if (strstr($check, $start_str))
		$camogm_running = "on";
	else
		$camogm_running = "off";
		
	if ($camogm_running=="on"){
		$pipe="/var/state/camogm.state";
		$mode=0777;
		if(!file_exists($pipe)) {
@@ -140,6 +158,10 @@ else if ($cmd == "status")
		fclose($fcmd);
	
		$status=file_get_contents($pipe);
	}else{
		$status = "<?xml version='1.0'?><camogm_state>\n<state>".$camogm_running."</state>\n</camogm_state>";
	}
		
	header("Content-Type: text/xml");
	header("Content-Length: ".strlen($status)."\n");
	header("Pragma: no-cache\n");