Merge
This commit is contained in:
commit
6bd1563f9b
1 changed files with 6 additions and 4 deletions
|
@ -30,7 +30,7 @@ class Sync{
|
||||||
// We're the main process.
|
// We're the main process.
|
||||||
} else {
|
} else {
|
||||||
$pid = getmypid();
|
$pid = getmypid();
|
||||||
if(!file_exists($pidfile) or (file_exists($pidfile) && Sync::check_pid(file_get_contents($pid)))) {
|
if(Sync::check_for_pid(@file_get_contents($pidfile))) {
|
||||||
$file = fopen($pidfile, 'w+');
|
$file = fopen($pidfile, 'w+');
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
echo $pidfile.' is not writeable.';
|
echo $pidfile.' is not writeable.';
|
||||||
|
@ -100,7 +100,7 @@ class Sync{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function check_pid($pid){
|
public static function check_for_pid($pid){
|
||||||
|
|
||||||
$OS = Sync::getOS();
|
$OS = Sync::getOS();
|
||||||
|
|
||||||
|
@ -113,10 +113,12 @@ class Sync{
|
||||||
continue;
|
continue;
|
||||||
$matches = false;
|
$matches = false;
|
||||||
preg_match( "/(.*?)\s+(\d+).*$/", $process, $matches );
|
preg_match( "/(.*?)\s+(\d+).*$/", $process, $matches );
|
||||||
$pid = $matches[ 2 ];
|
if ($pid = $matches[ 2 ]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return file_exists( "/proc/$pid" );
|
return file_exists( "/proc/".$pid );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static public function getOS() {
|
static public function getOS() {
|
||||||
|
|
Loading…
Reference in a new issue