diff options
author | Andrew Dolgov <[email protected]> | 2008-01-23 12:43:11 +0100 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2008-01-23 12:43:11 +0100 |
commit | 884c0a367b17d22d154fdb022c496b3e4ac777a8 (patch) | |
tree | 7171c53dbd476cf62b61d6dc36881a53ebb13a0d /update_daemon2.php | |
parent | 0bd6e68a85871bb91cb59a1bf2612e5d92b6eaaa (diff) |
update_daemon2: fix locking
Diffstat (limited to 'update_daemon2.php')
-rw-r--r-- | update_daemon2.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/update_daemon2.php b/update_daemon2.php index 53de6b3ef..68989c8e4 100644 --- a/update_daemon2.php +++ b/update_daemon2.php @@ -32,13 +32,22 @@ 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(); |