From a9c461626eac4c32b5b0a197909c81b62e7c8269 Mon Sep 17 00:00:00 2001
From: Christopher Faylor <me@cgf.cx>
Date: Wed, 15 Jun 2005 22:50:31 +0000
Subject: [PATCH] * cygthread.cc (cygthread::detach): Fix debugging output. *
 dcrt0.cc (dll_crt0_1): Create signal_arrived early -- before any filename
 manipulation. * sigproc.cc (sigproc_init): Don't create signal_arrived here.
 * fork.cc (fork_child): Ditto.

---
 winsup/cygwin/ChangeLog    | 8 ++++++++
 winsup/cygwin/cygthread.cc | 2 +-
 winsup/cygwin/dcrt0.cc     | 2 ++
 winsup/cygwin/fork.cc      | 3 ---
 winsup/cygwin/sigproc.cc   | 2 --
 winsup/cygwin/sigproc.h    | 1 +
 6 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 574ca7d73..e9c3827b4 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+2005-06-15  Christopher Faylor  <cgf@timesys.com>
+
+	* cygthread.cc (cygthread::detach): Fix debugging output.
+	* dcrt0.cc (dll_crt0_1): Create signal_arrived early -- before any
+	filename manipulation.
+	* sigproc.cc (sigproc_init): Don't create signal_arrived here.
+	* fork.cc (fork_child): Ditto.
+
 2005-06-14  Christopher Faylor  <cgf@timesys.com>
 
 	* path.cc (path_conv::check): Always reset to FH_FS when component != 0
diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc
index 896086834..f96908c0e 100644
--- a/winsup/cygwin/cygthread.cc
+++ b/winsup/cygwin/cygthread.cc
@@ -353,7 +353,7 @@ cygthread::detach (HANDLE sigwait)
 			case WAIT_TIMEOUT:
 			  break;
 			default:
-			  system_printf ("%s handle %p is bad", j ? "semaphore" : "signal_arrived", w4[j]);
+			  system_printf ("%s handle %p is bad", (j ? "signal_arrived" : "semaphore"), w4[j]);
 			  break;
 			}
 		    api_fatal ("exiting on fatal error");
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index ea0edbd0c..b119ba201 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -743,6 +743,8 @@ dll_crt0_1 (char *)
   strace.microseconds ();
 #endif
 
+  create_signal_arrived ();
+
   /* Initialize debug muto, if DLL is built with --enable-debugging.
      Need to do this before any helper threads start. */
   debug_init ();
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 5ecd3bbe4..504af292c 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -158,7 +158,6 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
 {
   extern void fixup_hooks_after_fork ();
   extern void fixup_timers_after_fork ();
-  extern void __stdcall create_signal_arrived ();
   debug_printf ("child is running.  pid %d, ppid %d, stack here %p",
 		myself->pid, myself->ppid, __builtin_frame_address (0));
 
@@ -204,8 +203,6 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
   if (fixup_mmaps_after_fork (hParent))
     api_fatal ("recreate_mmaps_after_fork_failed");
 
-  create_signal_arrived ();
-
 #ifdef USE_SERVER
   /* Incredible but true:  If we use sockets and SYSV IPC shared memory,
      there's a good chance that a duplicated socket in the child occupies
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 3e3b519dd..758bd5235 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -490,8 +490,6 @@ sigproc_init ()
    */
   sync_proc_subproc.init ("sync_proc_subproc");
 
-  create_signal_arrived ();
-
   hwait_sig = new cygthread (wait_sig, cygself, "sig");
   hwait_sig->zap_h ();
 
diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h
index a4e8a7147..a5b9a546c 100644
--- a/winsup/cygwin/sigproc.h
+++ b/winsup/cygwin/sigproc.h
@@ -79,6 +79,7 @@ int __stdcall sig_send (_pinfo *, int) __attribute__ ((regparm (2)));
 void __stdcall signal_fixup_after_exec ();
 void __stdcall wait_for_sigthread ();
 void __stdcall sigalloc ();
+void __stdcall create_signal_arrived ();
 
 int kill_pgrp (pid_t, siginfo_t&);
 int killsys (pid_t, int);