diff options
author | Christian Persch <chpe@gnome.org> | 2013-09-28 11:38:49 +0200 |
---|---|---|
committer | Christian Persch <chpe@gnome.org> | 2013-09-29 21:23:32 +0200 |
commit | c80fe16c3019eeb0686023b2968199e4d84a2676 (patch) | |
tree | 42eef8eeb8a8bb3da27d544a57827d2b9b85cc4d /src/vtestream-file.h | |
parent | a43839c166da7cc0a89bd7eb0b78b991bdff5471 (diff) | |
download | vte-c80fe16c3019eeb0686023b2968199e4d84a2676.tar.gz |
stream: file: Use O_TMPFILE when available
https://bugzilla.gnome.org/show_bug.cgi?id=704705
Diffstat (limited to 'src/vtestream-file.h')
-rw-r--r-- | src/vtestream-file.h | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/vtestream-file.h b/src/vtestream-file.h index c11a3155..f5624d1c 100644 --- a/src/vtestream-file.h +++ b/src/vtestream-file.h @@ -25,6 +25,7 @@ #include <gio/gunixinputstream.h> +#include "vteutils.h" #ifndef HAVE_PREAD #define pread _pread @@ -185,21 +186,15 @@ static inline void _vte_file_stream_ensure_fd0 (VteFileStream *stream) { gint fd; - gchar *file_name; + if (G_LIKELY (stream->fd[0])) return; - fd = g_file_open_tmp ("vteXXXXXX", &file_name, NULL); - if (fd != -1) { - unlink (file_name); - g_free (file_name); - } - - fcntl (fd, F_SETFL, O_NOATIME); - - stream->fd[0] = dup (fd); /* we do the dup to make sure ->fd[0] is not 0 */ + fd = _vte_mkstemp (); + if (fd == -1) + return; - close (fd); + stream->fd[0] = fd; } static void |