* Nix daemon: reload the configuration file after forking (NIX-100).

This commit is contained in:
Eelco Dolstra 2008-11-20 12:25:11 +00:00
parent c202523e53
commit a55113411f
3 changed files with 14 additions and 1 deletions

View file

@ -118,5 +118,12 @@ unsigned int queryIntSetting(const string & name, unsigned int def)
return n; return n;
} }
void reloadSettings()
{
settingsRead = false;
settings.clear();
}
} }

View file

@ -107,6 +107,8 @@ bool queryBoolSetting(const string & name, bool def);
unsigned int queryIntSetting(const string & name, unsigned int def); unsigned int queryIntSetting(const string & name, unsigned int def);
void reloadSettings();
} }

View file

@ -627,13 +627,17 @@ static void daemonLoop()
case 0: case 0:
try { /* child */ try { /* child */
/* Background the worker. */ /* Background the worker. */
if (setsid() == -1) if (setsid() == -1)
throw SysError(format("creating a new session")); throw SysError(format("creating a new session"));
/* Restore normal handling of SIGCHLD. */ /* Restore normal handling of SIGCHLD. */
setSigChldAction(false); setSigChldAction(false);
/* Since the daemon can be long-running, the
settings may have changed. So force a reload. */
reloadSettings();
/* Handle the connection. */ /* Handle the connection. */
from.fd = remote; from.fd = remote;