[prev in list] [next in list] [prev in thread] [next in thread]
List: openvz-criu
Subject: [CRIU] [PATCH 1/2] service: write pidfile before chdir to /, if going daemon
From: kupruser () gmail ! com (Ruslan Kuprieiev)
Date: 2013-10-29 23:27:33
Message-ID: 1383089254-5205-2-git-send-email-kupruser () gmail ! com
[Download RAW message or body]
Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
cr-service.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/cr-service.c b/cr-service.c
index 771944c..fbf9d20 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -303,7 +303,11 @@ int cr_service(bool daemon_mode)
}
if (daemon_mode) {
- if (daemon(0, 0) == -1) {
+ /*
+ * Will chdir to /, after writing pidfile,
+ * so pidfile path will be resolved properly.
+ */
+ if (daemon(1, 0) == -1) {
pr_perror("Can't run service server in the background");
goto err;
}
@@ -316,6 +320,14 @@ int cr_service(bool daemon_mode)
}
}
+ if (daemon_mode) {
+ /* And now we can chdir to /. */
+ if (chdir("/")) {
+ pr_perror("Can't chdir to /");
+ return -1;
+ }
+ }
+
/* FIXME Do not ignore children's return values */
signal(SIGCHLD, SIG_IGN);
--
1.8.1.2
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic