]> git.wh0rd.org Git - tt-rss.git/commitdiff
update_daemon2: fix locking
authorAndrew Dolgov <fox@madoka.spb.ru>
Wed, 23 Jan 2008 11:43:11 +0000 (12:43 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Wed, 23 Jan 2008 11:43:11 +0000 (12:43 +0100)
update_daemon2.php

index 53de6b3efa1712321df7046cf1ac47203d8749d7..68989c8e4a130bcfdd582fa70928a6d12c38a153 100644 (file)
        pcntl_signal(SIGCHLD, 'sigchld_handler');
        pcntl_signal(SIGINT, 'sigint_handler');
 
-       $lock_handle = make_lockfile("update_daemon.lock");
-
-       if (!$lock_handle) {
-               die("error: Can't create lockfile ($lock_filename). ".
+       if (file_is_locked("update_daemon.lock")) {
+               die("error: Can't create lockfile. ".
                        "Maybe another daemon is already running.\n");
        }
 
+       if (!pcntl_fork()) {
+               $lock_handle = make_lockfile("update_daemon.lock");
+
+               if (!$lock_handle) {
+                       die("error: Can't create lockfile. ".
+                               "Maybe another daemon is already running.\n");
+               }
+
+               while (true) { sleep(100); }
+       }
+
        while (true) {
 
                $next_spawn = $last_checkpoint + SPAWN_INTERVAL - time();