aboutsummaryrefslogtreecommitdiff
path: root/gdb/common/filestuff.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/common/filestuff.h')
-rw-r--r--gdb/common/filestuff.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/gdb/common/filestuff.h b/gdb/common/filestuff.h
index ecfc18d..9a12f83 100644
--- a/gdb/common/filestuff.h
+++ b/gdb/common/filestuff.h
@@ -20,6 +20,7 @@
#define FILESTUFF_H
#include <dirent.h>
+#include <fcntl.h>
/* Note all the file descriptors which are open when this is called.
These file descriptors will not be closed by close_most_fds. */
@@ -48,6 +49,16 @@ extern void close_most_fds (void);
extern int gdb_open_cloexec (const char *filename, int flags,
/* mode_t */ unsigned long mode);
+/* Like mkstemp, but ensures that the file descriptor is
+ close-on-exec. */
+
+static inline int
+gdb_mkostemp_cloexec (char *name_template, int flags = 0)
+{
+ /* gnulib provides a mkostemp replacement if needed. */
+ return mkostemp (name_template, flags | O_CLOEXEC);
+}
+
/* Convenience wrapper for the above, which takes the filename as an
std::string. */