diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index bb0d4b993..ffa6ab730 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,22 @@
+2006-03-22  Eric Blake  <ebb9@byu.net>
+
+	* fhandler.cc (fcntl): Print flags in hex.
+
+2006-03-22  Christopher Faylor  <cgf@timesys.com>
+
+	* dcrt0.cc (dll_crt0_0): Semi-revert 2006-03-14 change which moved
+	pinfo_init and uinfo_init here.
+	(dll_crt0_1): Ditto.
+	(__dll_crt0): Ditto. Don't call update_envptrs here.
+	(dll_crt0_1): Ditto. Move wait_for_sigthread call here from dll_crt0_0.
+	* environ.cc (environ_init): Call it here instead.
+	* sigproc.cc (my_readsig): New static variable.
+	(wait_for_sigthread): Set up read pipe here since we are assured that
+	we have the proper privileges when this is called.
+	(talktome): Eliminate second argument since it is available as a global
+	now.
+	(wait_sig): Reflect use of my_readsig.
+
 2006-03-22  Corinna Vinschen  <corinna@vinschen.de>
 
 	* thread.cc (pthread_cond::init): Disable validity test of object
@@ -58,8 +77,8 @@
 
 2006-03-19  Christopher Faylor  <cgf@timesys.com>
 
-	* dcrt0.cc (dll_crt0_0): Oops.  We need to bother with setting this in
-	the fork/exec case.
+	* dcrt0.cc (dll_crt0_0): Oops.  We need to bother with setting
+	init_console_handler in the fork/exec case.
 
 2006-03-19  Christopher Faylor  <cgf@timesys.com>
 
@@ -691,7 +710,7 @@
 
 2006-02-03  Corinna Vinschen  <corinna@vinschen.de>
 
-	* path.cc (suffix_scan::lnk_match): Return true beginning with 
+	* path.cc (suffix_scan::lnk_match): Return true beginning with
 	SCAN_APPENDLNK.
 	(suffix_scan::next): Rearrange code to make .lnk append order slightly
 	more deterministic.
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 5f7f2708b..971954fb3 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -754,12 +754,6 @@ dll_crt0_0 ()
   user_data->resourcelocks->Init ();
   user_data->threadinterface->Init ();
 
-  if (!in_forkee)
-    {
-      pinfo_init (envp, envc);
-      uinfo_init ();	/* initialize user info */
-    }
-
   _cygtls::init ();
 
   /* Initialize events */
@@ -838,6 +832,7 @@ dll_crt0_1 (char *)
   fork_init ();
   }
 #endif
+  pinfo_init (envp, envc);
 
   /* Can be set only after environment has been initialized. */
   if (wincap.has_security ())
@@ -849,6 +844,14 @@ dll_crt0_1 (char *)
   /* Allocate cygheap->fdtab */
   dtable_init ();
 
+  uinfo_init ();	/* initialize user info */
+
+  wait_for_sigthread ();
+  extern DWORD threadfunc_ix;
+  if (!threadfunc_ix)
+    system_printf ("internal error: couldn't determine location of thread function on stack.  Expect signal problems.");
+
+
   /* Connect to tty. */
   tty_init ();
 
@@ -960,13 +963,7 @@ initialize_main_tls (char *padding)
 extern "C" void __stdcall
 _dll_crt0 ()
 {
-  extern DWORD threadfunc_ix;
-  wait_for_sigthread ();
-  if (!threadfunc_ix)
-    system_printf ("internal error: couldn't determine location of thread function on stack.  Expect signal problems.");
-
   main_environ = user_data->envptr;
-  update_envptrs ();
 
   char padding[CYGTLS_PADSIZE];
 
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 1c934349f..99f61e7d6 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -809,6 +809,7 @@ environ_init (char **envp, int envc)
 
 out:
   __cygwin_environ = envp;
+  update_envptrs ();
   if (envp_passed_in)
     {
       p = getenv ("CYGWIN");
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 237aaadd7..b8c30da3c 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1304,7 +1304,7 @@ int fhandler_base::fcntl (int cmd, void *arg)
       break;
     case F_GETFL:
       res = get_flags ();
-      debug_printf ("GETFL: %d", res);
+      debug_printf ("GETFL: %p", res);
       break;
     case F_SETFL:
       {
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 0360d1a52..82d1b32b8 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -178,6 +178,7 @@ frok::child (void *)
   ld_preload ();
   fixup_hooks_after_fork ();
   _my_tls.fixup_after_fork ();
+  wait_for_sigthread ();
   cygwin_finished_initializing = true;
   return 0;
 }
@@ -545,10 +546,13 @@ fork ()
   void *esp;
   __asm__ volatile ("movl %%esp,%0": "=r" (esp));
 
-  if (!ischild)
-    res = grouped.parent (esp);
-  else
+  if (ischild)
     res = grouped.child (esp);
+  else
+    {
+      res = grouped.parent (esp);
+      sig_send (NULL, __SIGNOHOLD);
+    }
 
   MALLOC_CHECK;
   if (ischild || res > 0)
@@ -568,7 +572,6 @@ fork ()
 
       set_errno (grouped.this_errno);
     }
-  sig_send (NULL, __SIGNOHOLD);
   syscall_printf ("%d = fork()", res);
   return res;
 }
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 1adbb9f21..0f927fe89 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -64,7 +64,7 @@ HANDLE NO_COPY sigCONT;			// Used to "STOP" a process
 cygthread *hwait_sig;
 Static HANDLE wait_sig_inited;		// Control synchronization of
 					//  message queue startup
-static bool sigheld;			// True if holding signals
+static NO_COPY bool sigheld;		// True if holding signals
 
 Static int nprocs;			// Number of deceased children
 Static char cprocs[(NPROCS + 1) * sizeof (pinfo)];// All my children info
@@ -76,13 +76,15 @@ static muto NO_COPY sync_proc_subproc;	// Control access to subproc stuff
 
 _cygtls NO_COPY *_sig_tls;
 
+Static HANDLE my_sendsig;
+Static HANDLE my_readsig;
+
 /* Function declarations */
 static int __stdcall checkstate (waitq *) __attribute__ ((regparm (1)));
 static __inline__ bool get_proc_lock (DWORD, DWORD);
 static bool __stdcall remove_proc (int);
 static bool __stdcall stopped_or_terminated (waitq *, _pinfo *);
 static DWORD WINAPI wait_sig (VOID *arg);
-static HANDLE NO_COPY my_sendsig;
 
 /* wait_sig bookkeeping */
 
@@ -138,11 +140,17 @@ signal_fixup_after_exec ()
 void __stdcall
 wait_for_sigthread ()
 {
+  PSECURITY_ATTRIBUTES sa_buf = (PSECURITY_ATTRIBUTES) alloca (1024);
+  if (!CreatePipe (&my_readsig, &my_sendsig, sec_user_nih (sa_buf), 0))
+    api_fatal ("couldn't create signal pipe, %E");
+  ProtectHandle (my_readsig);
+  myself->sendsig = my_sendsig;
   sigproc_printf ("wait_sig_inited %p", wait_sig_inited);
   HANDLE hsig_inited = wait_sig_inited;
   WaitForSingleObject (hsig_inited, INFINITE);
   wait_sig_inited = NULL;
   ForceCloseHandle1 (hsig_inited, wait_sig_inited);
+  SetEvent (sigCONT);
 }
 
 /* Get the sync_proc_subproc muto to control access to
@@ -1049,7 +1057,7 @@ stopped_or_terminated (waitq *parent_w, _pinfo *child)
 }
 
 static void
-talktome (siginfo_t *si, HANDLE readsig)
+talktome (siginfo_t *si)
 {
   unsigned size = sizeof (*si);
   sigproc_printf ("pid %d wants some information", si->si_pid);
@@ -1057,12 +1065,12 @@ talktome (siginfo_t *si, HANDLE readsig)
     {
       size_t n;
       DWORD nb;
-      if (!ReadFile (readsig, &n, sizeof (n), &nb, NULL) || nb != sizeof (n))
+      if (!ReadFile (my_readsig, &n, sizeof (n), &nb, NULL) || nb != sizeof (n))
 	return;
       siginfo_t *newsi = (siginfo_t *) alloca (size += n + 1);
       *newsi = *si;
       newsi->_si_commune._si_str = (char *) (newsi + 1);
-      if (!ReadFile (readsig, newsi->_si_commune._si_str, n, &nb, NULL) || nb != n)
+      if (!ReadFile (my_readsig, newsi->_si_commune._si_str, n, &nb, NULL) || nb != n)
 	return;
       newsi->_si_commune._si_str[n] = '\0';
       si = newsi;
@@ -1121,17 +1129,10 @@ pending_signals::next ()
 static DWORD WINAPI
 wait_sig (VOID *)
 {
-  HANDLE readsig;
-  PSECURITY_ATTRIBUTES sa_buf = (PSECURITY_ATTRIBUTES) alloca (1024);
-
   /* Initialization */
   SetThreadPriority (GetCurrentThread (), WAIT_SIG_PRIORITY);
 
   sigCONT = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
-  if (!CreatePipe (&readsig, &my_sendsig, sec_user_nih (sa_buf), 0))
-    api_fatal ("couldn't create signal pipe, %E");
-  ProtectHandle (readsig);
-  myself->sendsig = my_sendsig;
 
   /* Setting dwProcessId flags that this process is now capable of receiving
      signals.  Prior to this, dwProcessId was set to the windows pid of
@@ -1145,19 +1146,18 @@ wait_sig (VOID *)
   SetEvent (wait_sig_inited);
 
   _sig_tls->init_threadlist_exceptions ();
-  debug_printf ("entering ReadFile loop, readsig %p, myself->sendsig %p",
-		readsig, myself->sendsig);
+  debug_printf ("entering ReadFile loop, my_readsig %p, myself->sendsig %p",
+		my_readsig, myself->sendsig);
 
   sigpacket pack;
-  if (in_forkee)
-    pack.si.si_signo = __SIGHOLD;
+  pack.si.si_signo = __SIGHOLD;
   for (;;)
     {
       if (pack.si.si_signo == __SIGHOLD)
 	WaitForSingleObject (sigCONT, INFINITE);
       DWORD nb;
       pack.tls = NULL;
-      if (!ReadFile (readsig, &pack, sizeof (pack), &nb, NULL))
+      if (!ReadFile (my_readsig, &pack, sizeof (pack), &nb, NULL))
 	break;
 
       if (nb != sizeof (pack))
@@ -1187,7 +1187,7 @@ wait_sig (VOID *)
       switch (pack.si.si_signo)
 	{
 	case __SIGCOMMUNE:
-	  talktome (&pack.si, readsig);
+	  talktome (&pack.si);
 	  break;
 	case __SIGSTRACE:
 	  strace.hello ();
@@ -1260,7 +1260,7 @@ wait_sig (VOID *)
 	break;
     }
 
-  ForceCloseHandle (readsig);
+  ForceCloseHandle (my_readsig);
   sigproc_printf ("signal thread exiting");
   ExitThread (0);
 }