]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Make finish_daemon() return a boolean to say whether it did anything.
authorNick Mathewson <nickm@torproject.org>
Wed, 8 Aug 2018 20:59:53 +0000 (16:59 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 8 Aug 2018 20:59:53 +0000 (16:59 -0400)
src/lib/process/daemon.c
src/lib/process/daemon.h

index 671579838e1232e65f53cdfc83de36d3329c588a..4836b3951c6456dcbeee716d2415645b9e8957c8 100644 (file)
@@ -102,15 +102,16 @@ start_daemon(void)
 /** Finish putting the process into daemon mode: drop standard fds, and tell
  * the parent process to exit.  (Note: it's safe to call this more than once:
  * calls after the first are ignored.  Calls start_daemon first if it hasn't
- * been called already.)
+ * been called already.) Return true if we actually did a fork; false if we
+ * didn't.
  */
-void
+int
 finish_daemon(const char *desired_cwd)
 {
   int nullfd;
   char c = '.';
   if (finish_daemon_called)
-    return;
+    return 0;
   if (!start_daemon_called)
     start_daemon();
   finish_daemon_called = 1;
@@ -149,6 +150,8 @@ finish_daemon(const char *desired_cwd)
     log_err(LD_GENERAL,"write failed. Exiting.");
   }
   close(daemon_filedes[1]);
+
+  return 0;
 }
 #else /* !(!defined(_WIN32)) */
 /* defined(_WIN32) */
index 1f26e9222157c580d62c0fd98827ae11428a8ea7..08cab17e128d179dca5c3a356a106ec313cb3367 100644 (file)
@@ -12,6 +12,6 @@
 #define TOR_DAEMON_H
 
 void start_daemon(void);
-void finish_daemon(const char *desired_cwd);
+int finish_daemon(const char *desired_cwd);
 
 #endif