git-daemon: don't ignore pid-file write failure
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> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jim Meyering committed
May 21, 2007 at 09:58 UTC
bc4e7d035840539eb5aa13ab3d51ab43cc2c1b50
1 file changed
+2
-2
daemon.c
+2
-2
@@ -970,8 +970,8 @@ static void store_pid(const char *path)
970
FILE *f = fopen(path, "w");
971
if (!f)
972
die("cannot open pid file %s: %s", path, strerror(errno));
973
- fprintf(f, "%d\n", getpid());
974
- fclose(f);
973
+ if (fprintf(f, "%d\n", getpid()) < 0 || fclose(f) != 0)
974
+ die("failed to write pid file %s: %s", path, strerror(errno));
975
}
976
977
static int serve(char *listen_addr, int listen_port, struct passwd *pass, gid_t gid)