This is the mail archive of the
mailing list for the GDB project.
[commit] Close the executable after it exits
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Wed, 30 Apr 2008 14:25:12 -0400
- Subject: [commit] Close the executable after it exits
BFD maintains a cache of open files and knows how to reopen closed ones
when we want their contents. We take advantage of this to stop
holding on to the executable. But not often enough - witness the
messy failure of chng-syms.exp whenever the host is Windows or
Cygwin (Windows cares about open handles when replacing files).
We already call bfd_cache_close_all after loading it and after kill.
This arranges for it to be called after every time we try to reopen
it, even if the mtime has not changed. Tested on mips-linux-gnu and
2008-04-30 Daniel Jacobowitz <email@example.com>
* corefile.c (reopen_exec_file): Close any open files.
--- corefile.c (revision 1022)
+++ corefile.c (local)
@@ -164,6 +164,11 @@ reopen_exec_file (void)
if (exec_bfd_mtime && exec_bfd_mtime != st.st_mtime)
exec_file_attach (filename, 0);
+ /* If we accessed the file since last opening it, close it now;
+ this stops GDB from holding the executable open after it
+ exits. */
+ bfd_cache_close_all ();