Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-07-14 01:08:13 +0400
committerChristopher Faylor <me@cgf.cx>2002-07-14 01:08:13 +0400
commitc03dba93d622f3d81d0c5ccea96f67f095de2631 (patch)
tree6988b4251f344a3fb43bda0e76189aab7159b89b /winsup/cygwin/dcrt0.cc
parent0301bfd0ac66697d974d3855cbf1ebb900c70932 (diff)
* dcrt0.cc (dll_crt0_1): Delay closing of some handles until cygheap has been
set up. (break_here): New function, for debugging. (initial_env): Add program name to "Sleeping" message. Implement new "CYGWIN_DEBUG" environment variable option. * exceptions.cc (debugger_command): Add argument to dumper call. * strace.cc (strace::hello): Use winpid if cygwin pid is unavailable. (strace::vsprntf): Ditto.
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r--winsup/cygwin/dcrt0.cc44
1 files changed, 38 insertions, 6 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 9c31a5b20..1ba328f45 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -583,18 +583,20 @@ dll_crt0_1 ()
if (child_proc_info)
{
+ bool close_ppid_handle = false;
+ bool close_hexec_proc = false;
switch (child_proc_info->type)
{
case _PROC_FORK:
cygheap_fixup_in_child (0);
alloc_stack (fork_info);
set_myself (mypid);
+ close_ppid_handle = !!child_proc_info->pppid_handle;
break;
case _PROC_SPAWN:
- if (spawn_info->hexec_proc)
- CloseHandle (spawn_info->hexec_proc);
- if (child_proc_info->pppid_handle)
- CloseHandle (child_proc_info->pppid_handle);
+ /* Have to delay closes until after cygheap is setup */
+ close_hexec_proc = !!spawn_info->hexec_proc;
+ close_ppid_handle = !!child_proc_info->pppid_handle;
goto around;
case _PROC_EXEC:
hexec_proc = spawn_info->hexec_proc;
@@ -621,6 +623,10 @@ dll_crt0_1 ()
}
break;
}
+ if (close_hexec_proc)
+ CloseHandle (spawn_info->hexec_proc);
+ if (close_ppid_handle)
+ CloseHandle (child_proc_info->pppid_handle);
debug_fixup_after_fork_exec ();
}
@@ -774,22 +780,48 @@ dll_crt0_1 ()
exit (user_data->main (__argc, __argv, *user_data->envptr));
}
+#ifdef DEBUGGING
+void
+break_here ()
+{
+ debug_printf ("break here");
+}
+#endif
+
void
initial_env ()
{
+ DWORD len;
char buf[MAX_PATH + 1];
#ifdef DEBUGGING
if (GetEnvironmentVariable ("CYGWIN_SLEEP", buf, sizeof (buf) - 1))
{
- console_printf ("Sleeping %d, pid %u\n", atoi (buf), GetCurrentProcessId ());
+ buf[0] = '\0';
+ len = GetModuleFileName (NULL, buf, MAX_PATH);
+ console_printf ("Sleeping %d, pid %u %s\n", atoi (buf), GetCurrentProcessId (), buf);
Sleep (atoi (buf));
}
+ if (GetEnvironmentVariable ("CYGWIN_DEBUG", buf, sizeof (buf) - 1))
+ {
+ char buf1[MAX_PATH + 1];
+ len = GetModuleFileName (NULL, buf1, MAX_PATH);
+ char *p = strchr (buf, '=');
+ if (!p)
+ p = "gdb.exe -nw";
+ else
+ *p++ = '\0';
+ if (strstr (buf1, buf))
+ {
+ error_start_init (p);
+ try_to_debug ();
+ break_here ();
+ }
+ }
#endif
if (GetEnvironmentVariable ("CYGWIN_TESTING", buf, sizeof (buf) - 1))
{
_cygwin_testing = 1;
- DWORD len;
if ((len = GetModuleFileName (cygwin_hmodule, buf, MAX_PATH))
&& len > sizeof ("new-cygwin1.dll")
&& strcasematch (buf + len - sizeof ("new-cygwin1.dll"),