Do not reopen temporary files
authorTom Tromey <tom@tromey.com>
Thu, 20 Sep 2018 22:30:47 +0000 (16:30 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 27 Oct 2018 17:58:41 +0000 (11:58 -0600)
commit36033ef57cd048588f9a3d5523712147066421f2
treec5e9a94e4f5eb6b7c4bd50fe3baf53cd52eee73f
parentb3279b601e67ce47263082ef86cfc86e25607c5e
Do not reopen temporary files

The current callers of mkostemp close the file descriptor and then
re-open it with fopen.  It seemed better to me to continue to use the
already-opened file descriptor, so this patch rearranges the code a
little in order to do so.  It takes care to ensure that the files are
only unlinked after the file descriptor in question is closed, as
before.

gdb/ChangeLog
2018-10-27  Tom Tromey  <tom@tromey.com>

* unittests/scoped_fd-selftests.c (test_to_file): New function.
(run_tests): Call test_to_file.
* dwarf-index-write.c (write_psymtabs_to_index): Do not reopen
temporary files.
* common/scoped_fd.h (scoped_fd::to_file): New method.
gdb/ChangeLog
gdb/common/scoped_fd.h
gdb/dwarf-index-write.c
gdb/unittests/scoped_fd-selftests.c