Git development
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering.net>
To: git@vger.kernel.org
Subject: [PATCH] git-daemon: don't ignore pid-file write failure
Date: Mon, 21 May 2007 09:58:01 +0200	[thread overview]
Message-ID: <878xbiboc6.fsf@rho.meyering.net> (raw)

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

                 reply	other threads:[~2007-05-21  7:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878xbiboc6.fsf@rho.meyering.net \
    --to=jim@meyering.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox