From d58c7f05e0b809063d8acfff5d1d4132d915a80d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A9ri=20Le=20Bouder?= Date: Fri, 20 Jul 2012 15:04:44 +0200 Subject: [PATCH] preserve the current location in daemon mode This is done, already if libdir is relative. closes: #1717 Reported-by: Nicolas Richard --- lib/FusionInventory/Agent.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/FusionInventory/Agent.pm b/lib/FusionInventory/Agent.pm index 07a00cb211..45f1833bfe 100644 --- a/lib/FusionInventory/Agent.pm +++ b/lib/FusionInventory/Agent.pm @@ -143,8 +143,17 @@ sub init { $logger->error("Can't load Proc::Daemon. Is the module installed?"); exit 1; } + + my $cwd = getcwd(); Proc::Daemon::Init(); $logger->debug("Daemon started"); + + + # If we use relative path, we must stay in the current directory + if (substr( $params{libdir}, 0, 1 ) ne '/') { + chdir($cwd); + } + if ($self->_isAlreadyRunning()) { $logger->debug("An agent is already runnnig, exiting..."); exit 1;