OSDN Git Service

* cygheap.h (init_cygheap): Play more vfork shell games and move ctty_on_hold
authorcgf <cgf>
Sat, 3 Jan 2004 18:15:02 +0000 (18:15 +0000)
committercgf <cgf>
Sat, 3 Jan 2004 18:15:02 +0000 (18:15 +0000)
and open_fhs_on_hold (back) here.
* dcrt0.cc (_dll_crt0): Just set impure_ptr_ptr here and let later
initialization deal with tls.
* dtable.cc (dtable::vfork_child_fixup): Move ctty considerations here.
(dtable:vfork_parent_restore): And here.
* fork.cc (vfork): Reflect change to ctty handling.
* perthread.h (vfork_save::fhctty): Eliminate.
* cygwin.din: Make more exports NOSIGFE that will never be interrupted by a
signal.
* init.cc (dll_entry): Set stackptr to NULL to catch problems earlier.

winsup/cygwin/ChangeLog
winsup/cygwin/cygheap.h
winsup/cygwin/cygtls.h
winsup/cygwin/cygwin.din
winsup/cygwin/dcrt0.cc
winsup/cygwin/dtable.cc
winsup/cygwin/fork.cc
winsup/cygwin/include/cygwin/version.h
winsup/cygwin/init.cc
winsup/cygwin/perthread.h

index d330ea2..9f2b44c 100644 (file)
@@ -1,3 +1,19 @@
+2004-01-02  Christopher Faylor  <cgf@redhat.com>
+
+       * cygheap.h (init_cygheap): Play more vfork shell games and move
+       ctty_on_hold and open_fhs_on_hold (back) here.
+       * dcrt0.cc (_dll_crt0): Just set impure_ptr_ptr here and let later
+       initialization deal with tls.
+       * dtable.cc (dtable::vfork_child_fixup): Move ctty considerations here.
+       (dtable:vfork_parent_restore): And here.
+       * fork.cc (vfork): Reflect change to ctty handling.
+       * perthread.h (vfork_save::fhctty): Eliminate.
+
+       * cygwin.din: Make more exports NOSIGFE that will never be interrupted
+       by a signal.
+
+       * init.cc (dll_entry): Set stackptr to NULL to catch problems earlier.
+
 2003-12-31  Christopher Faylor  <cgf@redhat.com>
 
        * cygwin.din: Make crt0 functions NOSIGFE.
index af21814..6aef317 100644 (file)
@@ -262,6 +262,7 @@ struct init_cygheap
   struct sigaction *sigs;
 
   fhandler_tty_slave *ctty;    /* Current tty */
+  fhandler_tty_slave *ctty_on_hold;
   int open_fhs;
 };
 
index 9253683..f11c65b 100644 (file)
@@ -28,6 +28,8 @@ details. */
 # define UNLEN 256
 #endif
 
+#define TLS_STACK_SIZE 1024
+
 #pragma pack(push,4)
 struct _local_storage
 {
@@ -107,7 +109,7 @@ struct _threadinfo
   struct _threadinfo *prev, *next;
   __stack_t *stackptr;
   int sig;
-  __stack_t stack[1024];
+  __stack_t stack[TLS_STACK_SIZE];
 
   /*gentls_offsets*/
   static CRITICAL_SECTION protect_linked_list;
index f60d2d5..1f3fe08 100644 (file)
@@ -34,7 +34,7 @@ __fpclassifyd NOSIGFE
 __fpclassifyf NOSIGFE
 __getreent NOSIGFE
 __infinity NOSIGFE
-__main SIGFE
+__main NOSIGFE
 __signbitd NOSIGFE
 __signbitf NOSIGFE
 __signgam NOSIGFE
@@ -43,7 +43,7 @@ __swbuf SIGFE
 _asprintf_r SIGFE
 asprintf_r = _asprintf_r SIGFE
 _dll_crt0@0 NOSIGFE
-_exit SIGFE
+_exit NOSIGFE
 _f_atan2 NOSIGFE
 __f_atan2 = _f_atan2 NOSIGFE
 _f_atan2f NOSIGFE
@@ -290,9 +290,9 @@ cygwin_conv_to_posix_path SIGFE
 cygwin32_conv_to_posix_path = cygwin_conv_to_posix_path SIGFE
 cygwin_conv_to_win32_path SIGFE
 cygwin32_conv_to_win32_path = cygwin_conv_to_win32_path SIGFE
-cygwin_detach_dll SIGFE
-cygwin32_detach_dll = cygwin_detach_dll SIGFE
-cygwin_dll_init SIGFE
+cygwin_detach_dll NOSIGFE
+cygwin32_detach_dll = cygwin_detach_dll NOSIGFE
+cygwin_dll_init NOSIGFE
 endprotoent = cygwin_endprotoent SIGFE
 endservent = cygwin_endservent SIGFE
 endusershell SIGFE
@@ -434,7 +434,7 @@ execve SIGFE
 _execve = execve SIGFE
 execvp SIGFE
 _execvp = execvp SIGFE
-exit = cygwin_exit SIGFE
+exit = cygwin_exit NOSIGFE
 exp NOSIGFE
 _exp = exp NOSIGFE
 exp2 NOSIGFE
index 1922cc5..3a3d689 100644 (file)
@@ -916,12 +916,11 @@ _dll_crt0 ()
 void
 dll_crt0 (per_process *uptr)
 {
-  char padding[CYGTLS_PADSIZE];
   /* Set the local copy of the pointer into the user space. */
   if (uptr && uptr != user_data)
     {
       memcpy (user_data, uptr, per_process_overwrite);
-      *(user_data->impure_ptr_ptr) = initialize_main_tls (padding);
+      *(user_data->impure_ptr_ptr) = &reent_data;
     }
   _dll_crt0 ();
 }
index e5bb802..141e173 100644 (file)
@@ -745,8 +745,13 @@ dtable::vfork_parent_restore ()
   fds = fds_on_hold;
   fds_on_hold = NULL;
   cfree (deleteme);
-
   ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "restore");
+
+  cygheap->ctty = cygheap->ctty_on_hold;       // revert
+  if (cygheap->ctty)
+    cygheap->ctty->close ();                   // Undo previous bump of this archetype
+  cygheap->ctty_on_hold = NULL;
+
   return;
 }
 
@@ -777,6 +782,12 @@ dtable::vfork_child_fixup ()
   cfree (fds_on_hold);
   fds_on_hold = NULL;
 
+  if (cygheap->ctty_on_hold)
+    {
+      cygheap->ctty_on_hold->close ();
+      cygheap->ctty_on_hold = NULL;
+    }
+
   return;
 }
 
index 477d85c..5671d1c 100644 (file)
@@ -719,7 +719,7 @@ vfork ()
       vf->ctty = myself->ctty;
       vf->sid = myself->sid;
       vf->pgid = myself->pgid;
-      vf->fhctty = cygheap->ctty;
+      cygheap->ctty_on_hold = cygheap->ctty;
       vf->open_fhs = cygheap->open_fhs;
       int res = cygheap->fdtab.vfork_child_dup () ? 0 : -1;
       debug_printf ("%d = vfork()", res);
@@ -739,20 +739,8 @@ vfork ()
   myself->ctty = vf->ctty;
   myself->sid = vf->sid;
   myself->pgid = vf->pgid;
-  termios_printf ("cygheap->ctty %p, vf->fhctty %p", cygheap->ctty, vf->fhctty);
-  if (cygheap->ctty != vf->fhctty)
-    {
-      vf->fhctty->close ();
-      if (vf->pid <= 0)
-       {
-         if (vf->ctty)
-           vf->fhctty->close ();
-         cygheap->ctty = vf->fhctty;
-       }
-    }
-
-  if (vf->pid <= 0)
-    cygheap->open_fhs = vf->open_fhs;
+  termios_printf ("cygheap->ctty %p, cygheap->ctty_on_hold %p", cygheap->ctty, cygheap->ctty_on_hold);
+  cygheap->open_fhs = vf->open_fhs;
 
   if (vf->pid < 0)
     {
index 4b083d0..1a91721 100644 (file)
@@ -34,8 +34,8 @@ details. */
    that didn't invalidate existing executables.  Both numbers were
    recorded in the executable and in the dll.
 
-   In October 1998 (starting with Cygwin 19.6), we started a new
-   means of Cygwin versioning: */
+   In October 1998 (starting with Cygwin 19.6), we started a new method
+   of Cygwin versioning: */
 
       /* The DLL major and minor numbers correspond to the "version of
         the Cygwin shared library".  This version is used to track important
index 61da81f..8bae79e 100644 (file)
@@ -53,7 +53,7 @@ dll_entry (HANDLE h, DWORD reason, void *static_load)
     case DLL_PROCESS_ATTACH:
       dynamically_loaded = (static_load == NULL);
       // __cygwin_user_data.impure_ptr = &_my_tls.local_clib;
-      _my_tls.stackptr = _my_tls.stack;
+      _my_tls.stackptr = NULL;
       break;
     case DLL_PROCESS_DETACH:
       break;
index e0efffc..593f779 100644 (file)
@@ -59,7 +59,6 @@ class vfork_save
   int ctty;
   pid_t sid;
   pid_t pgid;
-  class fhandler_tty_slave *fhctty;
   int open_fhs;
   int is_active () { return pid < 0; }
   void restore_pid (int val)