summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-14 17:57:09 +0800
committerwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-14 17:57:09 +0800
commitf351443e7276e0123585fd8c4b1564a7473837de (patch)
tree02a885bfe4c94fc08dcc03d4c73f9d34bd71981e
parent365ada238f8c08dec8797583ce20b000ce41ec73 (diff)
downloadpttbbs-f351443e7276e0123585fd8c4b1564a7473837de.tar
pttbbs-f351443e7276e0123585fd8c4b1564a7473837de.tar.gz
pttbbs-f351443e7276e0123585fd8c4b1564a7473837de.tar.bz2
pttbbs-f351443e7276e0123585fd8c4b1564a7473837de.tar.lz
pttbbs-f351443e7276e0123585fd8c4b1564a7473837de.tar.xz
pttbbs-f351443e7276e0123585fd8c4b1564a7473837de.tar.zst
pttbbs-f351443e7276e0123585fd8c4b1564a7473837de.zip
chdir after opening files, so relative paths work
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4612 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--common/sys/daemon.c10
1 files changed, 5 insertions, 5 deletions
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)