From: Jim Meyering Date: Mon, 21 May 2007 07:58:01 +0000 (+0200) Subject: git-daemon: don't ignore pid-file write failure X-Git-Tag: v1.5.2.1~18^2~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bc4e7d035840539eb5aa13ab3d51ab43cc2c1b50;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/daemon.c b/daemon.c index e74ecac95..674e30dca 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)