summaryrefslogtreecommitdiffstats
path: root/cat/virt-ls.c
diff options
context:
space:
mode:
Diffstat (limited to 'cat/virt-ls.c')
-rw-r--r--cat/virt-ls.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/cat/virt-ls.c b/cat/virt-ls.c
index b79afa31..3d3699ee 100644
--- a/cat/virt-ls.c
+++ b/cat/virt-ls.c
@@ -36,6 +36,10 @@
#include "guestfs.h"
#include "options.h"
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
+
/* Currently open libguestfs handle. */
guestfs_h *g;
@@ -468,7 +472,7 @@ do_ls_R (const char *dir)
/* The output of find0 is a \0-separated file. Turn each \0 into
* a \n character.
*/
- fd = open (tmpfile, O_RDONLY);
+ fd = open (tmpfile, O_RDONLY|O_CLOEXEC);
if (fd == -1) {
perror (tmpfile);
exit (EXIT_FAILURE);