From ca58a350958105f5529fb14504f4e229b675e39f Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Sat, 20 Oct 2018 15:45:58 -0400 Subject: Only use pidfile(3) on FreeBSD --- README | 2 +- server.c | 9 ++++++++- torus.1 | 2 ++ 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 a62b286..ade834d 100644 --- a/server.c +++ b/server.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -34,6 +33,10 @@ #include #include +#ifdef __FreeBSD__ +#include +#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. -- cgit 1.4.1 bin/1sh/libedit/Makefile (unfollow)
Commit message (Expand)Author
2019-09-12Consume entire bodyJune McEnroe
2019-09-10Add title -v flagJune McEnroe
2019-09-10Use curl error bufferJune McEnroe
2019-09-10Set Accept-Encoding in titleJune McEnroe
2019-09-08Set title User-AgentJune McEnroe
2019-09-07Add -x flag to titleJune McEnroe
2019-09-07Ignore SIGPIPE in relayJune McEnroe
2019-09-07Add A Memory Called EmpireJune McEnroe
2019-09-05Handle lack of Content-TypeJune McEnroe
2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe
2019-09-05Decode entities in titlesJune McEnroe
2019-09-05Print title as soon as it's availableJune McEnroe
2019-09-05Use CURL_PREFIX to set flagsJune McEnroe
2019-09-05Add titleJune McEnroe
2019-09-04Add Avorter n'est pas tuerJune McEnroe
2019-08-29Unset executable on shell scriptsJune McEnroe
2019-08-29Add long-missing setopt to bin.7June McEnroe
2019-08-29Add editJune McEnroe