summaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
authorTomasz Torcz <tomek@pipebreaker.pl>2015-01-09 22:17:50 +0100
committerNick Mathewson <nickm@torproject.org>2015-01-11 11:14:08 -0500
commitb17918726d2ec221556d707f06bb92cfa3830183 (patch)
treefe5ac3e0e61612c91ef0f2d2514c86b489dadaba /src/or/config.c
parent180ecd6a2b3ee9fe10fed760d30ac9fb72b03346 (diff)
downloadtor-b17918726d2ec221556d707f06bb92cfa3830183.tar.gz
tor-b17918726d2ec221556d707f06bb92cfa3830183.zip
send PID of the main daemon to supervisor
If running under systemd, notify the supervisor about current PID of Tor daemon. This makes systemd unit simpler and more robust: it will do the right thing regardless of RunAsDaemon settings.
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c
index a1347b9d7d..781f15a42d 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -55,6 +55,16 @@
#include "procmon.h"
+#ifdef HAVE_SYSTEMD
+# if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__)
+/* Systemd's use of gcc's __INCLUDE_LEVEL__ extension macro appears to confuse
+ * Coverity. Here's a kludge to unconfuse it.
+ */
+# define __INCLUDE_LEVEL__ 2
+# endif
+#include <systemd/sd-daemon.h>
+#endif
+
/* From main.c */
extern int quiet_level;
@@ -1018,6 +1028,11 @@ options_act_reversible(const or_options_t *old_options, char **msg)
start_daemon();
}
+#ifdef HAVE_SYSTEMD
+ /* Our PID may have changed, inform supervisor */
+ sd_notifyf(0, "MAINPID=%ld\n", (long int)getpid());
+#endif
+
#ifndef HAVE_SYS_UN_H
if (options->ControlSocket || options->ControlSocketsGroupWritable) {
*msg = tor_strdup("Unix domain sockets (ControlSocket) not supported "