about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-10-20 15:45:58 -0400
committerJune McEnroe <june@causal.agency>2018-10-20 15:45:58 -0400
commit1056dca533c84e168e69a5af54fc90ba5d718612 (patch)
tree0c3d472aae8fa0b71d02ca3d4fc35a3c07831b2c
parentAdd server daemonization (diff)
downloadtorus-1056dca533c84e168e69a5af54fc90ba5d718612.tar.gz
torus-1056dca533c84e168e69a5af54fc90ba5d718612.zip
Only use pidfile(3) on FreeBSD daemon
Diffstat (limited to '')
-rw-r--r--README2
-rw-r--r--server.c9
-rw-r--r--torus.12
3 files changed, 11 insertions, 2 deletions
diff --git a/README b/README
index 743a4e6..67c4dcc 100644
--- a/README
+++ b/README
@@ -39,7 +39,7 @@ DESCRIPTION
      -h      Write help page data to standard output and exit.
 
      -p pidfile
-             Daemonize and write PID to pidfile.
+             Daemonize and write PID to pidfile.  Only available on FreeBSD.
 
      -s sock
              Set path to UNIX-domain socket.  The default path is torus.sock.
diff --git a/server.c b/server.c
index 7edf3f2..cff6d21 100644
--- a/server.c
+++ b/server.c
@@ -19,7 +19,6 @@
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <libutil.h>
 #include <signal.h>
 #include <stdbool.h>
 #include <stdint.h>
@@ -34,6 +33,10 @@
 #include <time.h>
 #include <unistd.h>
 
+#ifdef __FreeBSD__
+#include <libutil.h>
+#endif
+
 #include "torus.h"
 
 static struct Tile *tiles;
@@ -371,11 +374,13 @@ int main(int argc, char *argv[]) {
 		}
 	}
 
+#ifdef __FreeBSD__
 	struct pidfh *pid = NULL;
 	if (pidPath) {
 		pid = pidfile_open(pidPath, 0600, NULL);
 		if (!pid) err(EX_CANTCREAT, "%s", pidPath);
 	}
+#endif
 
 	tilesMap(dataPath);
 
@@ -390,11 +395,13 @@ int main(int argc, char *argv[]) {
 	error = bind(server, (struct sockaddr *)&addr, SUN_LEN(&addr));
 	if (error) err(EX_CANTCREAT, "%s", sockPath);
 
+#ifdef __FreeBSD__
 	if (pid) {
 		error = daemon(0, 0);
 		if (error) err(EX_OSERR, "daemon");
 		pidfile_write(pid);
 	}
+#endif
 
 	error = listen(server, 0);
 	if (error) err(EX_OSERR, "listen");
diff --git a/torus.1 b/torus.1
index 6bad6be..cf4f702 100644
--- a/torus.1
+++ b/torus.1
@@ -101,6 +101,8 @@ Write help page data to standard output and exit.
 .It Fl p Ar pidfile
 Daemonize and write PID to
 .Ar pidfile .
+Only available on
+.Fx .
 .
 .It Fl s Ar sock
 Set path to UNIX-domain socket.
ed&follow=1'>Add DO YOU DOUBT ME TRAITORJune McEnroe 2019-12-22Add license header to cgit CSSJune McEnroe As requested. Funny that its license header capitalizes You. 2019-12-22Add The Book of EttaJune McEnroe 2019-12-21Revert "Add first working version of imbox"June McEnroe Moved to <https://git.causal.agency/imbox>. This reverts commit 6aa7f2f6bf47fa9df9c749ce665171fa30800937. 2019-12-21Add first working version of imboxJune McEnroe 2019-12-20Respect mailmap in gl pretty formatJune McEnroe 2019-12-20Set LANG in cgit filtersJune McEnroe ttpre needs to know about UTF-8 too so it can bold/italic non-ASCII chars. 2019-12-20Source .editrc before applying -v or -eJune McEnroe Otherwise a bind -v in .editrc will take precedence and overwrite the ^I binding for sh-complete. 2019-12-20Disable signing commitsJune McEnroe Why did I ever turn this on? This gets me nothing but inconvenience. RIP to all the wasted bytes in my git repos. 2019-12-19Ignore about-filterJune McEnroe 2019-12-19Fix matching make tags with no sourcesJune McEnroe 2019-12-19Avoid matching := assignments as tagsJune McEnroe 2019-12-18Hide line numbers when rendering mdocJune McEnroe Hack: output an extra <td> after rendering mdoc so that line numbers can be hidden based on there being three. This required splitting source-filter and about-filter since on about pages there is no table. 2019-12-18Customize cgit CSSJune McEnroe 2019-12-18Use :target rather than :focus pseudo-classJune McEnroe :target persists after you click on something else. 2019-12-18Copy cgit auxiliary binaries properlyJune McEnroe 2019-12-18Add git.causal.agency cgit configJune McEnroe 2019-12-18Bail from hi if input is binaryJune McEnroe NULs in the input cause an infinite loop in htmlEscape, not to mention regexes obviously not working, etc. 2019-12-16Post "cgit setup"June McEnroe