summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Youngman <jay@gnu.org>2010-03-29 12:30:23 +0200
committerJim Meyering <meyering@redhat.com>2010-03-29 12:30:32 +0200
commit7dfa1250265017223e36c72713a7521421b4d27c (patch)
tree4e9f8c8192f97d9e0d29ddde1fdc8087b0f453f6
parent6e0a75f9d908bb6d9f1039d1255d2513eafa9959 (diff)
downloadgnulib-7dfa1250265017223e36c72713a7521421b4d27c.tar.gz
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.
-rw-r--r--ChangeLog7
-rw-r--r--lib/save-cwd.c2
-rw-r--r--modules/save-cwd1
3 files changed, 10 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b863db0d9b..b6f1dc11e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-03-28 James Youngman <jay@gnu.org>
+
+ 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-29 Bruno Haible <bruno@clisp.org>
Remove vestiges of fts-lgpl module.
diff --git a/lib/save-cwd.c b/lib/save-cwd.c
index 7394d50acc..cf43a35500 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 46a1276abd..aab5e5ef49 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