fts: Make more robust in multithreaded applications.
authorBruno Haible <bruno@clisp.org>
Thu, 28 May 2020 19:48:13 +0000 (21:48 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 28 May 2020 19:48:13 +0000 (21:48 +0200)
* lib/fts.c (fts_open): Pass an O_CLOEXEC flag to open().
* modules/fts (Depends-on): Add 'open'.

ChangeLog
lib/fts.c
modules/fts

index e637b5772c6c7a638547f242241963fb27563785..4145796a5d62ce8238d1a6f3af4c47569ef90600 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-28  Bruno Haible  <bruno@clisp.org>
+
+       fts: Make more robust in multithreaded applications.
+       * lib/fts.c (fts_open): Pass an O_CLOEXEC flag to open().
+       * modules/fts (Depends-on): Add 'open'.
+
 2020-05-28  Bruno Haible  <bruno@clisp.org>
 
        relocatable-prog: Make more robust in multithreaded applications.
index 3b2f693b4432117806d0dbf2d7324a7ab39be9d2..5e357bee590efe4816d0e19d912928cc36193f3e 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -402,7 +402,7 @@ fts_open (char * const *argv,
                early, doing it here saves us the trouble of ensuring
                later (where it'd be messier) that "." can in fact
                be opened.  If not, revert to FTS_NOCHDIR mode.  */
-            int fd = open (".", O_SEARCH);
+            int fd = open (".", O_SEARCH | O_CLOEXEC);
             if (fd < 0)
               {
                 /* Even if "." is unreadable, don't revert to FTS_NOCHDIR mode
index 480700b1ca8a9be9e3434340e518058400f95bf2..b06d5b832188983f9a05bdbf0635cc8b234d46d7 100644 (file)
@@ -22,6 +22,7 @@ hash
 i-ring
 lstat
 memmove
+open
 openat-h
 opendir
 opendirat