tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit 622a2c6bee19af3bab0e84702a36ff2df39db7e7
parent 4f300d547d65e50ac1fd635f8b22714c1544ba33
Author: Nick Mathewson <nickm@torproject.org>
Date:   Wed,  8 Aug 2018 16:59:53 -0400

Make finish_daemon() return a boolean to say whether it did anything.

Diffstat:
Msrc/lib/process/daemon.c | 9++++++---
Msrc/lib/process/daemon.h | 2+-
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/lib/process/daemon.c b/src/lib/process/daemon.c @@ -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) */ diff --git a/src/lib/process/daemon.h b/src/lib/process/daemon.h @@ -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