aboutsummaryrefslogtreecommitdiff
path: root/src/supervise-daemon/supervise-daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/supervise-daemon/supervise-daemon.c')
-rw-r--r--src/supervise-daemon/supervise-daemon.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/supervise-daemon/supervise-daemon.c b/src/supervise-daemon/supervise-daemon.c
index adf35630..845b118c 100644
--- a/src/supervise-daemon/supervise-daemon.c
+++ b/src/supervise-daemon/supervise-daemon.c
@@ -817,6 +817,19 @@ int main(int argc, char **argv)
char **child_argv = NULL;
char *str = NULL;
char *cmdline = NULL;
+ char *svcdir = RC_SVCDIR;
+ char *pidfile_path = "/var/run";
+#ifdef RC_USER_SERVICES
+ char *env;
+ if (rc_is_user()) {
+ svcdir = rc_user_svcdir();
+ if ((env = getenv("XDG_RUNTIME_DIR"))) {
+ pidfile_path = env;
+ } else {
+ pidfile_path = "/tmp/"
+ }
+ }
+#endif
applet = basename_c(argv[0]);
atexit(cleanup);
@@ -1085,8 +1098,14 @@ int main(int argc, char **argv)
umask(numask);
if (!pidfile)
- xasprintf(&pidfile, "/var/run/supervise-%s.pid", svcname);
- xasprintf(&fifopath, "%s/supervise-%s.ctl", RC_SVCDIR, svcname);
+ xasprintf(&pidfile, "%s/supervise-%s.pid", pidfile_path, svcname);
+ xasprintf(&fifopath, "%s/supervise-%s.ctl", svcdir, svcname);
+#ifdef RC_USER_SERVICES
+ if (rc_is_user()) {
+ free(svcdir);
+ }
+#endif
+
if (mkfifo(fifopath, 0600) == -1 && errno != EEXIST)
eerrorx("%s: unable to create control fifo: %s",
applet, strerror(errno));