summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9c18df1)
raw | patch | inline | side by side (parent: 9c18df1)
author | Junio C Hamano <junkio@cox.net> | |
Fri, 29 Dec 2006 08:30:01 +0000 (00:30 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 29 Dec 2006 19:36:46 +0000 (11:36 -0800) |
I do not have any proof that this matters to any existing
problems I am seeing, but I do not think of any reason not to do
this.
Signed-off-by: Junio C Hamano <junkio@cox.net>
problems I am seeing, but I do not think of any reason not to do
this.
Signed-off-by: Junio C Hamano <junkio@cox.net>
sha1_file.c | patch | blob | history |
diff --git a/sha1_file.c b/sha1_file.c
index 84037fe98fa6ea0e4f1127c165786df51a34c5dd..d9622d95e7e3d7b91982ae60dbc36a7996856682 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
struct pack_header hdr;
unsigned char sha1[20];
unsigned char *idx_sha1;
+ long fd_flag;
p->pack_fd = open(p->pack_name, O_RDONLY);
if (p->pack_fd < 0 || fstat(p->pack_fd, &st))
} else if (p->pack_size != st.st_size)
die("packfile %s size changed", p->pack_name);
+ /* We leave these file descriptors open with sliding mmap;
+ * there is no point keeping them open across exec(), though.
+ */
+ fd_flag = fcntl(p->pack_fd, F_GETFD, 0);
+ if (fd_flag < 0)
+ die("cannot determine file descriptor flags");
+ fd_flag |= FD_CLOEXEC;
+ if (fcntl(p->pack_fd, F_SETFD, fd_flag) == -1)
+ die("cannot set FD_CLOEXEC");
+
/* Verify we recognize this pack file format. */
read_or_die(p->pack_fd, &hdr, sizeof(hdr));
if (hdr.hdr_signature != htonl(PACK_SIGNATURE))