From e9a546c68378927e4c67dbadd3bbfaedb83c747b Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 29 Oct 2019 08:54:30 +0100 Subject: [PATCH] Only chdir("/") when detaching from TTY and backgrounding process Signed-off-by: Joachim Nilsson --- src/syslogd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/syslogd.c b/src/syslogd.c index ebb0654..b0a4a8c 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -405,9 +405,6 @@ int main(int argc, char *argv[]) int num_fds, maxfds; int i, ch; -#ifndef TESTING - chdir("/"); -#endif for (i = 1; i < MAXFUNIX; i++) { funixn[i] = ""; funix[i] = -1; @@ -506,6 +503,8 @@ int main(int argc, char *argv[]) logit("Checking pidfile.\n"); if (!check_pid(PidFile)) { signal(SIGTERM, doexit); + chdir("/"); + if (fork()) { /* * Parent process