summaryrefslogtreecommitdiff
path: root/update_daemon2.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-02-25 21:59:26 +0400
committerAndrew Dolgov <[email protected]>2013-02-25 21:59:26 +0400
commitcfe6d444a99beb9085036374adfbd6dd5886f8bf (patch)
treea02e730a3d5cda8ec306ef843d88ac108aa34e1b /update_daemon2.php
parentf421fcd7e51d47628fe049f8fbe48f7c09ce0a26 (diff)
add workaround against shutdown() being called in child task context
Diffstat (limited to 'update_daemon2.php')
-rwxr-xr-xupdate_daemon2.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/update_daemon2.php b/update_daemon2.php
index b2b2cc982..4b6a43999 100755
--- a/update_daemon2.php
+++ b/update_daemon2.php
@@ -86,10 +86,12 @@
pcntl_waitpid(-1, $status, WNOHANG);
}
- function shutdown() {
- if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) {
- _debug("removing lockfile (master)...");
- unlink(LOCK_DIRECTORY . "/update_daemon.lock");
+ function shutdown($caller_pid) {
+ if ($caller_pid == posix_getpid()) {
+ if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) {
+ _debug("removing lockfile (master)...");
+ unlink(LOCK_DIRECTORY . "/update_daemon.lock");
+ }
}
}
@@ -104,7 +106,7 @@
function sigint_handler() {
_debug("[MASTER] SIG_INT received.\n");
- shutdown();
+ shutdown(posix_getpid());
die;
}
@@ -162,7 +164,7 @@
if (!$master_handlers_installed) {
_debug("[MASTER] installing shutdown handlers");
pcntl_signal(SIGINT, 'sigint_handler');
- register_shutdown_function('shutdown');
+ register_shutdown_function('shutdown', posix_getpid());
$master_handlers_installed = true;
}