{"thread":{"id":"8264","subject":"[PATCH] git-daemon: don't ignore pid-file write failure","startedAt":"2007-05-21T07:58:01Z","lastAt":"2007-05-21T07:58:01Z","messageCount":1,"participants":["Jim Meyering"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"42866","messageId":"878xbiboc6.fsf@rho.meyering.net","threadId":"8264","inReplyTo":null,"subject":"[PATCH] git-daemon: don't ignore pid-file write failure","fromName":"Jim Meyering","fromEmail":"jim@meyering.net","sentAt":"2007-05-21T07:58:01Z","receivedAt":"2007-05-21T07:58:01Z","isPatch":true,"sender":{"key":"jim@meyering.net","avatar":"https://avatars.githubusercontent.com/u/710630?v=4"},"body":"Note: since the consequence of failure is to call die,\nI don't bother to close \"f\".\n\nSigned-off-by: Jim Meyering <jim@meyering.net>\n---\n daemon.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/daemon.c b/daemon.c\nindex e74ecac..674e30d 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -970,8 +970,8 @@ static void store_pid(const char *path)\n \tFILE *f = fopen(path, \"w\");\n \tif (!f)\n \t\tdie(\"cannot open pid file %s: %s\", path, strerror(errno));\n-\tfprintf(f, \"%d\\n\", getpid());\n-\tfclose(f);\n+\tif (fprintf(f, \"%d\\n\", getpid()) < 0 || fclose(f) != 0)\n+\t\tdie(\"failed to write pid file %s: %s\", path, strerror(errno));\n }\n\n static int serve(char *listen_addr, int listen_port, struct passwd *pass, gid_t gid)\n--\n1.5.2\n"}]}