mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
added a chdir() for proper daemonizing
This commit is contained in:
19
repmgrd.c
19
repmgrd.c
@@ -1322,7 +1322,9 @@ update_registration(void)
|
||||
static void
|
||||
do_daemonize()
|
||||
{
|
||||
char *ptr, path[MAXLEN];
|
||||
pid_t pid = fork();
|
||||
|
||||
switch (pid)
|
||||
{
|
||||
case -1:
|
||||
@@ -1355,6 +1357,23 @@ do_daemonize()
|
||||
|
||||
/* a child just flows along */
|
||||
|
||||
memset(path, 0, MAXLEN);
|
||||
|
||||
for (ptr = config_file + strlen(config_file); ptr > config_file; --ptr)
|
||||
{
|
||||
if (*ptr == '/')
|
||||
{
|
||||
strncpy(path, config_file, ptr - config_file);
|
||||
}
|
||||
}
|
||||
|
||||
if (*path == '\0')
|
||||
{
|
||||
*path = '/';
|
||||
}
|
||||
|
||||
chdir(path);
|
||||
|
||||
break;
|
||||
|
||||
default: /* parent process */
|
||||
|
||||
Reference in New Issue
Block a user