diff options
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 72 |
1 files changed, 22 insertions, 50 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 0cda2e5d5..5cee5f16d 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -1,7 +1,7 @@ /* dcrt0.cc -- essentially the main() for the Cygwin dll Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc. + 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. This file is part of Cygwin. @@ -353,8 +353,7 @@ build_argv (char *cmd, char **&argv, int &argc, int winshell) } } - if (argv) - argv[argc] = NULL; + argv[argc] = NULL; debug_printf ("argc %d", argc); } @@ -599,17 +598,6 @@ child_info_fork::handle_fork () "user heap", cygheap->user_heap.base, cygheap->user_heap.ptr, NULL); - /* If my_wr_proc_pipe != NULL then it's a leftover handle from a previously - forked process. Close it now or suffer confusion with the parent of our - parent. */ - if (my_wr_proc_pipe) - ForceCloseHandle1 (my_wr_proc_pipe, wr_proc_pipe); - - /* Setup our write end of the process pipe. Clear the one in the structure. - The destructor should never be called for this but, it can't hurt to be - safe. */ - my_wr_proc_pipe = wr_proc_pipe; - rd_proc_pipe = wr_proc_pipe = NULL; /* Do the relocations here. These will actually likely be overwritten by the below child_copy but we do them here in case there is a read-only section which does not get copied by fork. */ @@ -626,36 +614,18 @@ child_info_fork::handle_fork () api_fatal ("recreate_mmaps_after_fork_failed"); } -bool -child_info_spawn::get_parent_handle () -{ - parent = OpenProcess (PROCESS_VM_READ, false, parent_winpid); - moreinfo->myself_pinfo = NULL; - return !!parent; -} - void child_info_spawn::handle_spawn () { extern void fixup_lockf_after_exec (); HANDLE h; - if (!dynamically_loaded || get_parent_handle ()) - { - cygheap_fixup_in_child (true); - memory_init (false); - } + cygheap_fixup_in_child (true); + memory_init (false); if (!moreinfo->myself_pinfo || !DuplicateHandle (GetCurrentProcess (), moreinfo->myself_pinfo, GetCurrentProcess (), &h, 0, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)) h = NULL; - - /* Setup our write end of the process pipe. Clear the one in the structure. - The destructor should never be called for this but, it can't hurt to be - safe. */ - my_wr_proc_pipe = wr_proc_pipe; - rd_proc_pipe = wr_proc_pipe = NULL; - myself.thisproc (h); __argc = moreinfo->argc; __argv = moreinfo->argv; @@ -677,15 +647,10 @@ child_info_spawn::handle_spawn () ready (true); - /* Keep pointer to parent open if we've execed so that pid will not be reused. - Otherwise, we no longer need this handle so close it. - Need to do this after debug_fixup_after_fork_exec or DEBUGGING handling of + /* Need to do this after debug_fixup_after_fork_exec or DEBUGGING handling of handles might get confused. */ - if (type != _CH_EXEC && child_proc_info->parent) - { - CloseHandle (child_proc_info->parent); - child_proc_info->parent = NULL; - } + CloseHandle (child_proc_info->parent); + child_proc_info->parent = NULL; signal_fixup_after_exec (); fixup_lockf_after_exec (); @@ -718,7 +683,6 @@ init_windows_system_directory () void dll_crt0_0 () { - wincap.init (); child_proc_info = get_cygwin_startup_info (); init_windows_system_directory (); init_global_security (); @@ -761,18 +725,24 @@ dll_crt0_0 () cygwin_user_h = child_proc_info->user_h; switch (child_proc_info->type) { - case _CH_FORK: - fork_info->handle_fork (); - break; - case _CH_SPAWN: - case _CH_EXEC: - spawn_info->handle_spawn (); - break; + case _CH_FORK: + fork_info->handle_fork (); + break; + case _CH_SPAWN: + case _CH_EXEC: + spawn_info->handle_spawn (); + break; } } user_data->threadinterface->Init (); + _cygtls::init (); + + /* Initialize events */ + events_init (); + tty_list::init_session (); + _main_tls = &_my_tls; /* Initialize signal processing here, early, in the hopes that the creation @@ -837,6 +807,8 @@ dll_crt0_1 (void *) strace.microseconds (); #endif + create_signal_arrived (); /* FIXME: move into wait_sig? */ + /* Initialize debug muto, if DLL is built with --enable-debugging. Need to do this before any helper threads start. */ debug_init (); |