]> sourceware.org Git - newlib-cygwin.git/commitdiff
* fhandler_tty.cc (fhandler_tty_common::dup): Just copy cygheap->ctty to child
authorChristopher Faylor <me@cgf.cx>
Wed, 10 Dec 2003 03:19:19 +0000 (03:19 +0000)
committerChristopher Faylor <me@cgf.cx>
Wed, 10 Dec 2003 03:19:19 +0000 (03:19 +0000)
if duping the current ctty.
(fhandler_tty_common::close): Move debugging statement earlier in function.
(fhandler_tty_slave::close): Return success when closing ctty.
* syscalls.cc (close_all_files): Avoid calling fhandler_tty_slave close method
so that open_fhs will not be decremented when closing cygheap ctty.
(setsid): Ditto.
* dcrt0.cc (do_exit): Reorganize to avoid leaving a critical section active
after vfork.
* fhandler.h (fhandler_tty_slave::get_unit): Remove regparm parameter since it
can't work in a virtualized function.

winsup/cygwin/ChangeLog
winsup/cygwin/dcrt0.cc
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_tty.cc
winsup/cygwin/syscalls.cc

index 78e66fbb5bc09a439dfb3450efe83f6e197845f4..6f732d12cb879eb1f95c68d17eebf6065e5cf894 100644 (file)
@@ -1,3 +1,18 @@
+2003-12-09  Christopher Faylor  <cgf@redhat.com>
+
+       * fhandler_tty.cc (fhandler_tty_common::dup): Just copy cygheap->ctty
+       to child if duping the current ctty.
+       (fhandler_tty_common::close): Move debugging statement earlier in function.
+       (fhandler_tty_slave::close): Return success when closing ctty.
+       * syscalls.cc (close_all_files): Avoid calling fhandler_tty_slave close
+       method so that open_fhs will not be decremented when closing cygheap
+       ctty.
+       (setsid): Ditto.
+       * dcrt0.cc (do_exit): Reorganize to avoid leaving a critical section
+       active after vfork.
+       * fhandler.h (fhandler_tty_slave::get_unit): Remove regparm parameter
+       since it can't work in a virtualized function.
+
 2003-12-08  Christopher Faylor  <cgf@redhat.com>
 
        * pinfo.cc (_pinfo::set_ctty): Don't copy over existing ctty if it is
index 0f6a133a3e0f9a394c7955b85935afab2002f2aa..31655c0bd73d9a522e4446929c5e802a9eed8b67 100644 (file)
@@ -952,21 +952,23 @@ extern CRITICAL_SECTION exit_lock;
 void __stdcall
 do_exit (int status)
 {
+  syscall_printf ("do_exit (%d), exit_state %d", status, exit_state);
+
+  vfork_save *vf = vfork_storage.val ();
+  if (vf != NULL && vf->pid < 0)
+    {
+      exit_state = ES_NOT_EXITING;
+      vf->restore_exit (status);
+    }
+
+  EnterCriticalSection (&exit_lock);
   if (exit_state < ES_EVENTS_TERMINATE)
     {
       exit_state = ES_EVENTS_TERMINATE;
       events_terminate ();
     }
 
-  EnterCriticalSection (&exit_lock);
   UINT n = (UINT) status;
-
-  syscall_printf ("do_exit (%d)", n);
-
-  vfork_save *vf = vfork_storage.val ();
-  if (vf != NULL && vf->pid < 0)
-    vf->restore_exit (status);
-
   if (exit_state < ES_THREADTERM)
     {
       exit_state = ES_THREADTERM;
index 6014325b400043d70807287fe35535697e92cade..b90e3bfb64dacd0fada91b16bffcbf282a85d917 100644 (file)
@@ -918,7 +918,7 @@ class fhandler_tty_slave: public fhandler_tty_common
   _off64_t lseek (_off64_t, int) { return 0; }
   select_record *select_read (select_record *s);
   int cygserver_attach_tty (HANDLE*, HANDLE*);
-  int get_unit () __attribute__ ((regparm (1)));
+  int get_unit ();
   virtual char const *ttyname () { return pc.dev.name; }
 };
 
index 3cea6b9d02ea918c4b63d0953af763ac0ce10cf4..34f6a7bff3cf5c24a5f5e370a8f4c8bf49eb654a 100644 (file)
@@ -603,7 +603,7 @@ fhandler_tty_slave::close ()
     FreeConsole ();
   termios_printf ("decremented open_fhs %d", fhandler_console::open_fhs);
   if (myself->ctty >= 0 && get_io_handle () == cygheap->ctty.get_io_handle ())
-    return 1;
+    return 0;
   return fhandler_tty_common::close ();
 }
 
@@ -898,6 +898,14 @@ fhandler_tty_common::dup (fhandler_base *child)
   fhandler_tty_slave *fts = (fhandler_tty_slave *) child;
   int errind;
 
+debug_printf ("get_io_handle %p, cygheap->ctty.get_io_handle %p",get_io_handle (),cygheap->ctty.get_io_handle ());
+  if (get_io_handle () == cygheap->ctty.get_io_handle ())
+    {
+      *fts = cygheap->ctty;
+      termios_printf ("duped ctty");
+      return 0;
+    }
+
   fts->tcinit (get_ttyp ());
 
   attach_tty (get_unit ());
@@ -981,7 +989,7 @@ fhandler_tty_common::dup (fhandler_base *child)
     }
 
   if (get_major () == DEV_TTYS_MAJOR)
-    myself->set_ctty (get_ttyp (), openflags, (fhandler_tty_slave *) this);
+    myself->set_ctty (get_ttyp (), openflags, fts);
 
   return 0;
 
@@ -1147,6 +1155,7 @@ fhandler_pty_master::open (int flags, mode_t)
 int
 fhandler_tty_common::close ()
 {
+  termios_printf ("tty%d <%p,%p> closing", get_unit (), get_handle (), get_output_handle ());
   if (output_done_event && !CloseHandle (output_done_event))
     termios_printf ("CloseHandle (output_done_event), %E");
   if (ioctl_done_event && !CloseHandle (ioctl_done_event))
@@ -1174,10 +1183,8 @@ fhandler_tty_common::close ()
   if (!ForceCloseHandle1 (get_output_handle (), to_pty))
     termios_printf ("CloseHandle (get_output_handle ()<%p>), %E", get_output_handle ());
 
-  set_io_handle (NULL);
-
   inuse = NULL;
-  termios_printf ("tty%d <%p,%p> closed", get_unit (), get_handle (), get_output_handle ());
+  set_io_handle (NULL);
   return 0;
 }
 
index 268c34f467d5248ab46343409da48bbbbdd56049..1a77c360f4af11248fe155670737c4cee22aed5f 100644 (file)
@@ -98,10 +98,7 @@ close_all_files (void)
       }
 
   if (cygheap->ctty.get_io_handle ())
-    {
-      myself->ctty = -1;
-      cygheap->ctty.close ();
-    }
+    cygheap->ctty.fhandler_tty_common::close ();
 
   ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "close_all_files");
   user_shared->delqueue.process_queue ();
@@ -324,10 +321,7 @@ setsid (void)
       myself->sid = getpid ();
       myself->pgid = getpid ();
       if (cygheap->ctty.get_io_handle ())
-       {
-         cygheap->ctty.close ();
-         cygheap->ctty.set_io_handle (NULL);
-       }
+       cygheap->ctty.fhandler_tty_common::close ();
       syscall_printf ("sid %d, pgid %d, ctty %d, open_fhs %d", myself->sid,
                      myself->pgid, myself->ctty, fhandler_console::open_fhs);
       return myself->sid;
This page took 0.044288 seconds and 5 git commands to generate.