summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5f490ce)
raw | patch | inline | side by side (parent: 5f490ce)
author | Matthias Lederhofer <matled@gmx.net> | |
Thu, 13 Jul 2006 10:18:08 +0000 (12:18 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 14 Jul 2006 04:50:41 +0000 (21:50 -0700) |
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
daemon.c | patch | blob | history |
diff --git a/daemon.c b/daemon.c
index 01ccda33ea97dd62c00e6cfd63734fe39182f4ce..cdc42668633ec5a7b93544cca3fc92298d8556f4 100644 (file)
--- a/daemon.c
+++ b/daemon.c
close(fd);
}
+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);
+}
+
static int serve(int port)
{
int socknum, *socklist;
{
int port = DEFAULT_GIT_PORT;
int inetd_mode = 0;
+ const char *pid_file = NULL;
int i;
/* Without this we cannot rely on waitpid() to tell
user_path = arg + 12;
continue;
}
+ if (!strncmp(arg, "--pid-file=", 11)) {
+ pid_file = arg + 11;
+ continue;
+ }
if (!strcmp(arg, "--")) {
ok_paths = &argv[i+1];
break;
sanitize_stdfds();
+ if (pid_file)
+ store_pid(pid_file);
+
return serve(port);
}