* dcrt0.cc (dll_crt0_1): Move exception list and constructor stuff earlier in

the process.  Use new second argument to set_myself.
(cygwin_dll_init): Initialize exception list and constructor stuff here.
(_dll_crt0): And here.  Also, deal with inherited pinfo shared memory region
from parent.
* pinfo.cc (set_myself): Accept a second argument signifying the a shared
memory region, passed from an execing parent.
(pinfo_init): Ditto.
* pinfo.h: Ditto.
* shared.h (child_info): Add a handle field to pass to child.
* spawn.cc (spawn_guts): Create a shared handle to pass to an execed child.
* winsup.h: Remove extraneous declaration.
This commit is contained in:
Christopher Faylor
2000-08-24 04:07:50 +00:00
parent e1cf4ae80c
commit f5589e4118
7 changed files with 81 additions and 24 deletions

View File

@@ -615,12 +615,6 @@ sigthread::init (const char *s)
static void
dll_crt0_1 ()
{
/* According to onno@stack.urc.tue.nl, the exception handler record must
be on the stack. */
/* FIXME: Verify forked children get their exception handler set up ok. */
exception_list cygwin_except_entry;
do_global_ctors (&__CTOR_LIST__, 1);
#ifdef DEBUGGING
if (child_proc_info)
switch (child_proc_info->type)
@@ -666,7 +660,7 @@ dll_crt0_1 ()
// should be blocked.
if (mypid)
set_myself ((pid_t) mypid);
set_myself ((pid_t) mypid, NULL);
(void) SetErrorMode (SEM_FAILCRITICALERRORS);
@@ -683,11 +677,6 @@ dll_crt0_1 ()
instead of each time a file is opened. */
set_process_privileges ();
/* Initialize SIGSEGV handling, etc... Because the exception handler
references data in the shared area, this must be done after
shared_init. */
init_exceptions (&cygwin_except_entry);
if (user_data->forkee)
{
/* If we've played with the stack, stacksize != 0. That means that
@@ -812,6 +801,15 @@ extern "C" void __stdcall
_dll_crt0 ()
{
char zeros[sizeof (ciresrv->zero)] = {0};
/* According to onno@stack.urc.tue.nl, the exception handler record must
be on the stack. */
/* FIXME: Verify forked children get their exception handler set up ok. */
exception_list cygwin_except_entry;
/* Initialize SIGSEGV handling, etc... Because the exception handler
references data in the shared area, this must be done after
shared_init. */
init_exceptions (&cygwin_except_entry);
do_global_ctors (&__CTOR_LIST__, 1);
#ifdef DEBUGGING
char buf[80];
@@ -834,6 +832,7 @@ _dll_crt0 ()
DuplicateHandle (hMainProc, GetCurrentThread (), hMainProc,
&hMainThread, 0, FALSE, DUPLICATE_SAME_ACCESS);
HANDLE h;
GetStartupInfo (&si);
if (si.cbReserved2 >= EXEC_MAGIC_SIZE &&
memcmp (ciresrv->zero, zeros, sizeof (zeros)) == 0)
@@ -868,6 +867,14 @@ _dll_crt0 ()
case PROC_EXEC:
case PROC_SPAWN:
info = si.lpReserved2 + ciresrv->cb;
if (child_proc_info->myself_pinfo &&
DuplicateHandle (hMainProc, child_proc_info->myself_pinfo,
hMainProc, &h, 0, 0,
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
{
set_myself (mypid, h);
mypid = 0;
}
break;
case PROC_FORK:
case PROC_FORK1:
@@ -905,6 +912,16 @@ cygwin_dll_init ()
{
static char **envp;
static int _fmode;
/* According to onno@stack.urc.tue.nl, the exception handler record must
be on the stack. */
/* FIXME: Verify forked children get their exception handler set up ok. */
exception_list cygwin_except_entry;
/* Initialize SIGSEGV handling, etc... Because the exception handler
references data in the shared area, this must be done after
shared_init. */
init_exceptions (&cygwin_except_entry);
do_global_ctors (&__CTOR_LIST__, 1);
user_data->heapbase = user_data->heapptr = user_data->heaptop = NULL;
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),