mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +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
|
static void
|
||||||
do_daemonize()
|
do_daemonize()
|
||||||
{
|
{
|
||||||
|
char *ptr, path[MAXLEN];
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
|
|
||||||
switch (pid)
|
switch (pid)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
@@ -1355,6 +1357,23 @@ do_daemonize()
|
|||||||
|
|
||||||
/* a child just flows along */
|
/* 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;
|
break;
|
||||||
|
|
||||||
default: /* parent process */
|
default: /* parent process */
|
||||||
|
|||||||
Reference in New Issue
Block a user