git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-daemon: don't ignore pid-file write failure

From
Jim Meyering <jim@meyering.net>
Date
May 21, 2007, 07:58 UTC
Message-ID
<878xbiboc6.fsf@rho.meyering.net>
Note: since the consequence of failure is to call die,
I don't bother to close "f".
Signed-off-by: Jim Meyering <jim@meyering.net>
---
 daemon.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemon.c b/daemon.c
index e74ecac..674e30d 100644
--- a/daemon.c
+++ b/daemon.c
@@ -970,8 +970,8 @@ static void store_pid(const char *path)
 	FILE *f = fopen(path, "w");
 	if (!f)
 		die("cannot open pid file %s: %s", path, strerror(errno));
-	fprintf(f, "%d\n", getpid());
-	fclose(f);
+	if (fprintf(f, "%d\n", getpid()) < 0 || fclose(f) != 0)
+		die("failed to write pid file %s: %s", path, strerror(errno));
 }

 static int serve(char *listen_addr, int listen_port, struct passwd *pass, gid_t gid)
--
1.5.2
Message 1 of 1 in “git-daemon: don't ignore pid-file write failure”
  1. git-daemon: don't ignore pid-file write failureJim Meyering, May 21, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.