Code

git-daemon: don't ignore pid-file write failure
authorJim Meyering <jim@meyering.net>
Mon, 21 May 2007 07:58:01 +0000 (09:58 +0200)
committerJunio C Hamano <junkio@cox.net>
Tue, 22 May 2007 01:34:14 +0000 (18:34 -0700)
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>
daemon.c

index e74ecac952fa0d399a1ed0c426a9e27d96b3ddcb..674e30dca3d05cabc5a72e7bb0a40e64eaa4b2eb 100644 (file)
--- 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)