[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Findutils-patches] [PATCH] save-cwd: don't leak a file descriptor when
From: |
James Youngman |
Subject: |
[Findutils-patches] [PATCH] save-cwd: don't leak a file descriptor when the caller execs. |
Date: |
Mon, 29 Mar 2010 10:49:54 +0100 |
Signed-off-by: James Youngman <address@hidden>
---
ChangeLog | 7 +++++++
lib/save-cwd.c | 2 ++
modules/save-cwd | 1 +
3 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dca5a12..f9bd220 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-03-28 James Youngman <address@hidden>
+
+ save-cwd: don't leak a file descriptor when the caller execs.
+ * lib/save-cwd.c (save_cwd): set the close-on-exec flag for the
+ saved file descriptor.
+ * modules/save-cwd (Depends-on): Depend on cloexec.
+
2010-03-28 Bruno Haible <address@hidden>
Ralf Wildenhues <address@hidden>
diff --git a/lib/save-cwd.c b/lib/save-cwd.c
index 7394d50..cf43a35 100644
--- a/lib/save-cwd.c
+++ b/lib/save-cwd.c
@@ -31,6 +31,7 @@
#include "chdir-long.h"
#include "unistd--.h"
#include "xgetcwd.h"
+#include "cloexec.h"
#if GNULIB_FCNTL_SAFER
# include "fcntl--.h"
@@ -84,6 +85,7 @@ save_cwd (struct saved_cwd *cwd)
return cwd->name ? 0 : -1;
}
+ set_cloexec_flag (cwd->desc, true);
return 0;
}
diff --git a/modules/save-cwd b/modules/save-cwd
index 46a1276..aab5e5e 100644
--- a/modules/save-cwd
+++ b/modules/save-cwd
@@ -8,6 +8,7 @@ m4/save-cwd.m4
Depends-on:
chdir-long
+cloexec
stdbool
unistd-safer
xgetcwd
--
1.5.6.5
- [Findutils-patches] [PATCH] save-cwd: don't leak a file descriptor when the caller execs.,
James Youngman <=