From f351443e7276e0123585fd8c4b1564a7473837de Mon Sep 17 00:00:00 2001 From: wens Date: Sun, 14 Jun 2009 09:57:09 +0000 Subject: chdir after opening files, so relative paths work git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4612 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- common/sys/daemon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/sys/daemon.c b/common/sys/daemon.c index 4d925c1c..4d490cb4 100644 --- a/common/sys/daemon.c +++ b/common/sys/daemon.c @@ -41,11 +41,6 @@ daemonize(const char * pidfile, const char * logfile) if (pid > 0) exit(0); - if (chdir("/") < 0) { - perror("Can't chdir to root"); - exit(-1); - } - if (pidfile) { if ((fd = creat(pidfile, 0644)) >= 0) { snprintf(buf, sizeof(buf), "%d", (int)getpid()); @@ -66,6 +61,11 @@ daemonize(const char * pidfile, const char * logfile) } } + if (chdir("/") < 0) { + perror("Can't chdir to root"); + exit(-1); + } + #if 0 fd = getdtablesize(); while (fd > 2) -- cgit v1.2.3