summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ad8b4f5)
raw | patch | inline | side by side (parent: ad8b4f5)
author | Matthias Lederhofer <matled@gmx.net> | |
Thu, 13 Jul 2006 16:32:11 +0000 (18:32 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 14 Jul 2006 04:50:20 +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 a7636bc50c3d0148adaeaca5e624fcf1ab542d8d..01ccda33ea97dd62c00e6cfd63734fe39182f4ce 100644 (file)
--- a/daemon.c
+++ b/daemon.c
}
}
+/* if any standard file descriptor is missing open it to /dev/null */
+static void sanitize_stdfds(void)
+{
+ int fd = open("/dev/null", O_RDWR, 0);
+ while (fd != -1 && fd < 2)
+ fd = dup(fd);
+ if (fd == -1)
+ die("open /dev/null or dup failed: %s", strerror(errno));
+ if (fd > 2)
+ close(fd);
+}
+
static int serve(int port)
{
int socknum, *socklist;
return execute(peer);
}
+ sanitize_stdfds();
+
return serve(port);
}