aboutsummaryrefslogtreecommitdiff
path: root/gdb/ctf.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-09-18 16:45:59 -0600
committerTom Tromey <tom@tromey.com>2018-09-23 12:11:16 -0600
commit65773341ee5ad9e2882fcb1aed7c3096e6b4f190 (patch)
tree29432c01b92dce80017c39d9a25e310c5d6ec10e /gdb/ctf.c
parent1db88d2272a776200db950c2af46e64e98ef056b (diff)
downloadgdb-65773341ee5ad9e2882fcb1aed7c3096e6b4f190.zip
gdb-65773341ee5ad9e2882fcb1aed7c3096e6b4f190.tar.gz
gdb-65773341ee5ad9e2882fcb1aed7c3096e6b4f190.tar.bz2
Mark more file descriptors close-on-exec
I noticed a couple of spots in gdb that were opening files but not marking the file descriptors as close-on-exec. This patch fixes these. There are still a few more of these, but they are in code that I can't compile, so I'd prefer not to touch. gdb/ChangeLog 2018-09-23 Tom Tromey <tom@tromey.com> * ctf.c (ctf_start): Use gdb_fopen_cloexec. * common/scoped_mmap.c (mmap_file): Use gdb_open_cloexec.
Diffstat (limited to 'gdb/ctf.c')
-rw-r--r--gdb/ctf.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/gdb/ctf.c b/gdb/ctf.c
index a156b1f..43bb18e 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -31,6 +31,7 @@
#include "tracefile.h"
#include <ctype.h>
#include <algorithm>
+#include "common/filestuff.h"
/* The CTF target. */
@@ -354,7 +355,8 @@ ctf_start (struct trace_file_writer *self, const char *dirname)
std::string file_name = string_printf ("%s/%s", dirname, CTF_METADATA_NAME);
- writer->tcs.metadata_fd = fopen (file_name.c_str (), "w");
+ writer->tcs.metadata_fd
+ = gdb_fopen_cloexec (file_name.c_str (), "w").release ();
if (writer->tcs.metadata_fd == NULL)
error (_("Unable to open file '%s' for saving trace data (%s)"),
file_name.c_str (), safe_strerror (errno));
@@ -362,7 +364,8 @@ ctf_start (struct trace_file_writer *self, const char *dirname)
ctf_save_metadata_header (&writer->tcs);
file_name = string_printf ("%s/%s", dirname, CTF_DATASTREAM_NAME);
- writer->tcs.datastream_fd = fopen (file_name.c_str (), "w");
+ writer->tcs.datastream_fd
+ = gdb_fopen_cloexec (file_name.c_str (), "w").release ();
if (writer->tcs.datastream_fd == NULL)
error (_("Unable to open file '%s' for saving trace data (%s)"),
file_name.c_str (), safe_strerror (errno));