From 1d11384131349798b7f570c6b368c23f43fa4ffd Mon Sep 17 00:00:00 2001 From: Stefan Gehn Date: Wed, 22 Feb 2012 19:44:27 +0100 Subject: [PATCH] Abort gkrellmd detaching if chdir fails Handle the return value for chdir() and abort daemonizing of gkrellmd in case chdir failed. --- server/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/main.c b/server/main.c index a5a9e4e..cb51f45 100644 --- a/server/main.c +++ b/server/main.c @@ -1098,7 +1098,12 @@ detach_from_terminal(void) if (fd > 2) close(fd); } - chdir("/"); + + if (chdir("/") != 0) + { + g_warning("Detach failed in chdir(\"/\"): %s\n", strerror(errno)); + return FALSE; + } #endif /* HAVE_DAEMON */ // signal(SIGCHLD, SIG_IGN);