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>2006-03-13 21:29:48 +0300
committerChristopher Faylor <me@cgf.cx>2006-03-13 21:29:48 +0300
commitbbca1e4cb97050e1cc646730aedd8269f9474fc2 (patch)
tree1703fdf0f881af37489241232ddde413636be8da
parentd6382e653ac71b77675d569c225640f5b2683058 (diff)
* dcrt0.cc (dll_crt0_0): Reorganize so that sigproc_init is called a little
later. Add a comment. * fork.cc (resume_child): Make void. (frok::parent): Only zero pi when necessary. Explicitly zero si. Set this_errno when child_copy fails. Accommodate change to resume_child. * sigproc.cc (sigalloc): Move global_sigs initialization here. (sigproc_init): Move global_sigs. (sig_send): Just check for flush signals once. * wincap.h: Define supports_setconsolectrlhandler_null throughout. * wincap.cc: Ditto.
-rw-r--r--winsup/cygwin/ChangeLog14
-rw-r--r--winsup/cygwin/dcrt0.cc10
-rw-r--r--winsup/cygwin/fork.cc23
-rw-r--r--winsup/cygwin/sigproc.cc21
-rw-r--r--winsup/cygwin/wincap.cc39
-rw-r--r--winsup/cygwin/wincap.h2
6 files changed, 73 insertions, 36 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 61bdcc021..b99e6d9fe 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,17 @@
+2006-03-13 Christopher Faylor <cgf@timesys.com>
+
+ * dcrt0.cc (dll_crt0_0): Reorganize so that sigproc_init is called a
+ little later. Add a comment.
+ * fork.cc (resume_child): Make void.
+ (frok::parent): Only zero pi when necessary. Explicitly zero si. Set
+ this_errno when child_copy fails. Accommodate change to resume_child.
+ * sigproc.cc (sigalloc): Move global_sigs initialization here.
+ (sigproc_init): Move global_sigs.
+ (sig_send): Just check for flush signals once.
+
+ * wincap.h: Define supports_setconsolectrlhandler_null throughout.
+ * wincap.cc: Ditto.
+
2006-03-13 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (LoadDLLfuncNt): New define to wrap NT native functions.
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 9da090f30..149d37794 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -671,6 +671,13 @@ void __stdcall
dll_crt0_0 ()
{
init_global_security ();
+ initial_env ();
+
+ /* Initialize signal processing here, early, in the hopes that the creation
+ of a thread early in the process will cause more predictability in memory
+ layout for the main thread. */
+ sigproc_init ();
+
lock_process::init ();
init_console_handler (TRUE);
_impure_ptr = _GLOBAL_REENT;
@@ -680,7 +687,6 @@ dll_crt0_0 ()
_impure_ptr->_current_locale = "C";
user_data->impure_ptr = _impure_ptr;
user_data->impure_ptr_ptr = &_impure_ptr;
- initial_env ();
mmap_init ();
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),
@@ -750,8 +756,6 @@ dll_crt0_0 ()
DuplicateTokenEx (hProcToken, MAXIMUM_ALLOWED, NULL,
SecurityImpersonation, TokenImpersonation,
&hProcImpToken);
- /* Initialize signal/subprocess handling. */
- sigproc_init ();
debug_printf ("finished dll_crt0_0 initialization");
}
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 244bb71db..eba4337a1 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -50,12 +50,12 @@ class frok
friend int fork ();
};
-static int
+static void
resume_child (HANDLE forker_finished)
{
SetEvent (forker_finished);
debug_printf ("signalled child");
- return 1;
+ return;
}
/* Notify parent that it is time for the next step. */
@@ -214,7 +214,6 @@ frok::parent (void *stack_here)
{
HANDLE forker_finished;
DWORD rc;
- PROCESS_INFORMATION pi = {0, NULL, 0, 0};
child_pid = -1;
error = NULL;
this_errno = 0;
@@ -225,7 +224,6 @@ frok::parent (void *stack_here)
int c_flags = GetPriorityClass (hMainProc);
debug_printf ("priority class %d", c_flags);
- STARTUPINFO si = {0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL};
/* If we don't have a console, then don't create a console for the
child either. */
@@ -274,6 +272,10 @@ frok::parent (void *stack_here)
debug_printf ("stack - bottom %p, top %p, size %d",
ch.stackbottom, ch.stacktop, ch.stacksize);
+ PROCESS_INFORMATION pi;
+ STARTUPINFO si;
+
+ memset (&si, 0, sizeof (si));
si.cb = sizeof (STARTUPINFO);
si.lpReserved2 = (LPBYTE) &ch;
si.cbReserved2 = sizeof (ch);
@@ -300,6 +302,7 @@ frok::parent (void *stack_here)
{
this_errno = geterrno_from_win_error ();
error = "CreateProcessA failed";
+ memset (&pi, 0, sizeof (pi));
goto cleanup;
}
@@ -403,7 +406,10 @@ frok::parent (void *stack_here)
locked = false;
MALLOC_CHECK;
if (!rc)
- goto cleanup;
+ {
+ this_errno = get_errno ();
+ goto cleanup;
+ }
/* Now fill data/bss of any DLLs that were linked into the program. */
for (dll *d = dlls.istart (DLL_LINK); d; d = dlls.inext ())
@@ -422,10 +428,9 @@ frok::parent (void *stack_here)
}
}
- /* Start thread, and wait for it to reload dlls. */
- if (!resume_child (forker_finished))
- goto cleanup;
- else if (!ch.sync (child->pid, pi.hProcess, FORK_WAIT_TIMEOUT))
+ /* Start thread, and then wait for it to reload dlls. */
+ resume_child (forker_finished);
+ if (!ch.sync (child->pid, pi.hProcess, FORK_WAIT_TIMEOUT))
{
this_errno = EAGAIN;
error = "died waiting for dll loading";
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 845f7cd80..c8f11324a 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -112,6 +112,7 @@ sigalloc ()
{
cygheap->sigs = global_sigs =
(struct sigaction *) ccalloc (HEAP_SIGS, NSIG, sizeof (struct sigaction));
+ global_sigs[SIGSTOP].sa_flags = SA_RESTART | SA_NODEFER;
}
void __stdcall
@@ -479,14 +480,12 @@ sigproc_init ()
ProtectHandle (wait_sig_inited);
/* sync_proc_subproc is used by proc_subproc. It serialises
- * access to the children and proc arrays.
- */
+ access to the children and proc arrays. */
sync_proc_subproc.init ("sync_proc_subproc");
hwait_sig = new cygthread (wait_sig, 0, cygself, "sig");
hwait_sig->zap_h ();
- global_sigs[SIGSTOP].sa_flags = SA_RESTART | SA_NODEFER;
sigproc_printf ("process/signal handling enabled, state %p", myself->process_state);
}
@@ -514,20 +513,20 @@ sig_send (_pinfo *p, int sig)
sigheld = true;
else if (!sigheld)
/* nothing */;
- else if (sig != __SIGNOHOLD && sig != __SIGFLUSH && sig != __SIGFLUSHFAST)
- {
-#ifdef DEBUGGING
- system_printf ("internal signal sent while signals are on hold");
-#endif
- return -1;
- }
else if (sig == __SIGFLUSH || sig == __SIGFLUSHFAST)
return 0;
- else
+ else if (sig == __SIGNOHOLD)
{
SetEvent (sigCONT);
sigheld = false;
}
+ else
+ {
+#ifdef DEBUGGING
+ system_printf ("internal signal sent while signals are on hold");
+#endif
+ return -1;
+ }
siginfo_t si = {0};
si.si_signo = sig;
si.si_code = SI_KERNEL;
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index 6b6b0e11d..e1b09a05b 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -65,7 +65,8 @@ static NO_COPY wincaps wincap_unknown = {
has_working_virtual_lock:false,
has_disabled_user_tos_setting:false,
has_fileid_dirinfo:false,
- has_exclusiveaddruse:false
+ has_exclusiveaddruse:false,
+ supports_setconsolectrlhandler_null:false
};
static NO_COPY wincaps wincap_95 = {
@@ -122,7 +123,8 @@ static NO_COPY wincaps wincap_95 = {
has_working_virtual_lock:false,
has_disabled_user_tos_setting:false,
has_fileid_dirinfo:false,
- has_exclusiveaddruse:false
+ has_exclusiveaddruse:false,
+ supports_setconsolectrlhandler_null:false
};
static NO_COPY wincaps wincap_95osr2 = {
@@ -179,7 +181,8 @@ static NO_COPY wincaps wincap_95osr2 = {
has_working_virtual_lock:false,
has_disabled_user_tos_setting:false,
has_fileid_dirinfo:false,
- has_exclusiveaddruse:false
+ has_exclusiveaddruse:false,
+ supports_setconsolectrlhandler_null:false
};
static NO_COPY wincaps wincap_98 = {
@@ -236,7 +239,8 @@ static NO_COPY wincaps wincap_98 = {
has_working_virtual_lock:false,
has_disabled_user_tos_setting:false,
has_fileid_dirinfo:false,
- has_exclusiveaddruse:false
+ has_exclusiveaddruse:false,
+ supports_setconsolectrlhandler_null:false
};
static NO_COPY wincaps wincap_98se = {
@@ -293,7 +297,8 @@ static NO_COPY wincaps wincap_98se = {
has_working_virtual_lock:false,
has_disabled_user_tos_setting:false,
has_fileid_dirinfo:false,
- has_exclusiveaddruse:false
+ has_exclusiveaddruse:false,
+ supports_setconsolectrlhandler_null:false
};
static NO_COPY wincaps wincap_me = {
@@ -350,7 +355,8 @@ static NO_COPY wincaps wincap_me = {
has_working_virtual_lock:false,
has_disabled_user_tos_setting:false,
has_fileid_dirinfo:false,
- has_exclusiveaddruse:false
+ has_exclusiveaddruse:false,
+ supports_setconsolectrlhandler_null:false
};
static NO_COPY wincaps wincap_nt3 = {
@@ -407,7 +413,8 @@ static NO_COPY wincaps wincap_nt3 = {
has_working_virtual_lock:true,
has_disabled_user_tos_setting:false,
has_fileid_dirinfo:false,
- has_exclusiveaddruse:false
+ has_exclusiveaddruse:false,
+ supports_setconsolectrlhandler_null:true
};
static NO_COPY wincaps wincap_nt4 = {
@@ -464,7 +471,8 @@ static NO_COPY wincaps wincap_nt4 = {
has_working_virtual_lock:true,
has_disabled_user_tos_setting:false,
has_fileid_dirinfo:false,
- has_exclusiveaddruse:false
+ has_exclusiveaddruse:false,
+ supports_setconsolectrlhandler_null:true
};
static NO_COPY wincaps wincap_nt4sp4 = {
@@ -521,7 +529,8 @@ static NO_COPY wincaps wincap_nt4sp4 = {
has_working_virtual_lock:true,
has_disabled_user_tos_setting:false,
has_fileid_dirinfo:false,
- has_exclusiveaddruse:true
+ has_exclusiveaddruse:true,
+ supports_setconsolectrlhandler_null:true
};
static NO_COPY wincaps wincap_2000 = {
@@ -578,7 +587,8 @@ static NO_COPY wincaps wincap_2000 = {
has_working_virtual_lock:true,
has_disabled_user_tos_setting:true,
has_fileid_dirinfo:true,
- has_exclusiveaddruse:true
+ has_exclusiveaddruse:true,
+ supports_setconsolectrlhandler_null:true
};
static NO_COPY wincaps wincap_xp = {
@@ -635,7 +645,8 @@ static NO_COPY wincaps wincap_xp = {
has_working_virtual_lock:true,
has_disabled_user_tos_setting:true,
has_fileid_dirinfo:true,
- has_exclusiveaddruse:true
+ has_exclusiveaddruse:true,
+ supports_setconsolectrlhandler_null:true
};
static NO_COPY wincaps wincap_2003 = {
@@ -692,7 +703,8 @@ static NO_COPY wincaps wincap_2003 = {
has_working_virtual_lock:true,
has_disabled_user_tos_setting:true,
has_fileid_dirinfo:true,
- has_exclusiveaddruse:true
+ has_exclusiveaddruse:true,
+ supports_setconsolectrlhandler_null:true
};
static NO_COPY wincaps wincap_vista = {
@@ -749,7 +761,8 @@ static NO_COPY wincaps wincap_vista = {
has_working_virtual_lock:true,
has_disabled_user_tos_setting:true,
has_fileid_dirinfo:true,
- has_exclusiveaddruse:true
+ has_exclusiveaddruse:true,
+ supports_setconsolectrlhandler_null:true
};
wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
index d4edfd3da..a8c0e5bfc 100644
--- a/winsup/cygwin/wincap.h
+++ b/winsup/cygwin/wincap.h
@@ -67,6 +67,7 @@ struct wincaps
unsigned has_disabled_user_tos_setting : 1;
unsigned has_fileid_dirinfo : 1;
unsigned has_exclusiveaddruse : 1;
+ unsigned supports_setconsolectrlhandler_null : 1;
};
class wincapc
@@ -140,6 +141,7 @@ public:
bool IMPLEMENT (has_disabled_user_tos_setting)
bool IMPLEMENT (has_fileid_dirinfo)
bool IMPLEMENT (has_exclusiveaddruse)
+ bool IMPLEMENT (supports_setconsolectrlhandler_null)
#undef IMPLEMENT
};