This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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
checked in.

Daniel Jacobowitz

2008-04-30  Daniel Jacobowitz  <>

	* 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);
+  else
+    /* 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 ();

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]