summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-08-17 16:19:29 -0400
committerJune McEnroe <june@causal.agency>2020-08-17 16:21:34 -0400
commitebd44fb60618ce60fe269bfd3d1443db9cd8a362 (patch)
tree336aa0548fc86e428562da9e58cfba44d10442f0
parentUse a non-blocking lock on the PID file (diff)
downloadcatsit-ebd44fb60618ce60fe269bfd3d1443db9cd8a362.tar.gz
catsit-ebd44fb60618ce60fe269bfd3d1443db9cd8a362.zip
Use a separate fd for the fake fifo writer
From OpenBSD open(2):

> A FIFO should either be opened with O_RDONLY or with O_WRONLY.  The
> behavior for opening a FIFO with O_RDWR is undefined.
-rw-r--r--daemon.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/daemon.c b/daemon.c
index a1be594..785504f 100644
--- a/daemon.c
+++ b/daemon.c
@@ -265,13 +265,13 @@ int main(int argc, char *argv[]) {
 		warn("%s", fifoPath);
 	}
 
-	// XXX: Make sure there is always at least one writer open, otherwise we
-	// get EOF continually.
-	int fifo = open(fifoPath, O_RDWR | O_NONBLOCK | O_CLOEXEC);
-	if (fifo < 0) err(EX_CANTCREAT, "%s", fifoPath);
 	struct Line fifoLine = {0};
+	int fifo = open(fifoPath, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
+	if (fifo < 0) err(EX_CANTCREAT, "%s", fifoPath);
 
-	openlog(getprogname(), LOG_NDELAY | LOG_PID | LOG_PERROR, LOG_DAEMON);
+	// XXX: Keep a writer open so the reader never gets EOF.
+	int writer = open(fifoPath, O_WRONLY | O_NONBLOCK | O_CLOEXEC);
+	if (writer < 0) err(EX_CANTCREAT, "%s", fifoPath);
 
 	error = parseConfig(configPath);
 	if (error) return EX_DATAERR;
cgit-pink/commit/ui-shared.c?id=a360666df3cfcd1b384cd66b18803d72e3893b3d&follow=1'>ui-shared: show full date in tooltip if longer ago than max_relativeJohn Keeping 2015-08-13ui-shared: use common function in print_rel_date()John Keeping 2015-08-13ui-shared: extract date formatting to a functionJohn Keeping 2015-08-13filter: don't use dlsym unnecessarilyJohn Keeping 2015-08-13ui-tree: use "sane" isgraph()John Keeping 2015-08-13cgit.h: move stdbool.h from ui-shared.hJohn Keeping 2015-08-13cache.c: fix header orderJohn Keeping 2015-08-13configfile.c: don't include system headers directlyJohn Keeping 2015-08-13Remove redundant includesJohn Keeping 2015-08-13Makefile: include Git's config.mak.unameJohn Keeping 2015-08-13tests: allow shell to be overriddenJohn Keeping 2015-08-13redirect: cleanlinessJason A. Donenfeld 2015-08-13redirect: be more careful for different cgi setupsJason A. Donenfeld 2015-08-12ui-log: fix double countingJohn Keeping 2015-08-12log: allow users to follow a fileJohn Keeping 2015-08-12shared: make cgit_diff_tree_cb publicJohn Keeping 2015-08-12t0110: Chain together using &&Jason A. Donenfeld 2015-08-12about: always ensure page has a trailing slashJason A. Donenfeld 2015-08-12filters: apply HTML escapingLazaros Koromilas 2015-08-12git: update to v2.5.0Christian Hesse 2015-08-12Fix processing of repo.hide and repo.ignoreDaniel Reichelt