# Call exit() in the original process. The process that invoked the daemon must be able to rely on that this exit() happens after initialization is complete and all external communication channels are established and accessible.
# Call exit() in the original process. The process that invoked the daemon must be able to rely on that this exit() happens after initialization is complete and all external communication channels are established and accessible.
exit;
exit;
}
}
@ -320,4 +325,23 @@ USAGE_TEXT;
}
}
}
}
}
}
/** Resolves the PID file path and ensures the file or parent directory is writable */
protected function resolvePID(string $pidfile): string {
$dir = dirname($pidfile);
$file = basename($pidfile);
if ($base = @realpath($dir)) {
$out = "$base/$file";
if (file_exists($out)) {
if (!is_writable($out)) {
throw new \Exception("PID file is not writable");
}
} elseif (!is_writable($base)) {
throw new \Exception("Cannot create PID file");
}
} else {
throw new \Exception("Parent directory of PID file does not exist");