dll_list: Track main executable and cygwin1.dll.

Even for the main executable and cygwin1.dll store the file name as full
NT path.  Create the child process using the main executable's file name
converted from the full NT path stored before.

	* dll_init.cc (dll_list::alloc): Search for DLL_SELF type entry
	with module name like for DLL_LINK, use full NT path to search
	for DLL_LOAD type only.  For DLL_SELF type do not indicate
	having a destructor to be called.
	(dll_list::find): Ignore DLL_SELF type entries.
	(dll_list::init): Ditto.  Call track_self method.
	(dll_list::track_self): New.
	(dll_list::load_after_fork): Call track_self method.
	* dll_init.h (enum dll_type): Add DLL_SELF, for the main
	executable and cygwin1.dll.
	(struct dll_list): Declare private method track_self.  Declare
	member variable main_executable.
	* fork.cc (frok::parent): Use ntname from dlls.main_executable
	to create child process, converted to short path using
	dll_list::buffered_shortname.
This commit is contained in:
Michael Haubenwallner
2016-12-07 11:58:26 +01:00
committed by Corinna Vinschen
parent 2678c4efe1
commit dac0b6826b
3 changed files with 36 additions and 9 deletions

View File

@ -175,7 +175,7 @@ frok::child (volatile char * volatile here)
if (fixup_shms_after_fork ())
api_fatal ("recreate_shm areas after fork failed");
/* load dynamic dlls, if any */
/* load dynamic dlls, if any, re-track main-executable and cygwin1.dll */
dlls.load_after_fork (hParent);
cygheap->fdtab.fixup_after_fork (hParent);
@ -310,11 +310,20 @@ frok::parent (volatile char * volatile stack_here)
while (1)
{
PCWCHAR forking_progname = NULL;
if (dlls.main_executable)
forking_progname = dll_list::buffered_shortname
(dlls.main_executable->ntname);
if (!forking_progname || !*forking_progname)
forking_progname = myself->progname;
syscall_printf ("CreateProcessW (%W, %W, 0, 0, 1, %y, 0, 0, %p, %p)",
myself->progname, myself->progname, c_flags, &si, &pi);
forking_progname, myself->progname, c_flags, &si, &pi);
hchild = NULL;
rc = CreateProcessW (myself->progname, /* image to run */
/* cygwin1.dll may reuse the forking_progname buffer, even
in case of failure: don't reuse forking_progname later */
rc = CreateProcessW (forking_progname, /* image to run */
GetCommandLineW (), /* Take same space for command
line as in parent to make
sure child stack is allocated