OSDN Git Service

* cygerrno.h: Make multi-inclusion safe.
authorcgf <cgf>
Thu, 30 Jun 2005 02:52:09 +0000 (02:52 +0000)
committercgf <cgf>
Thu, 30 Jun 2005 02:52:09 +0000 (02:52 +0000)
* fhandler_termios.cc (fhandler_termios::tcsetpgrp): Deal with EINTR.
* dcrt0.cc (dll_crt0_0): Accommodate init_console_handler argument change.
* winsup.h: Ditto.
* fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
* exceptions.cc (init_console_handler): Ditto.  Ignore console events if we're
not attached to a terminal.
* fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
* wincap.cc: Implement has_null_console_handler_routine throughout.
* wincap.h: Ditto.

winsup/cygwin/ChangeLog
winsup/cygwin/cygerrno.h
winsup/cygwin/dcrt0.cc
winsup/cygwin/exceptions.cc
winsup/cygwin/fhandler_termios.cc
winsup/cygwin/fhandler_tty.cc
winsup/cygwin/wincap.cc
winsup/cygwin/wincap.h
winsup/cygwin/winsup.h

index 2b6a105..78d4fd7 100644 (file)
@@ -1,5 +1,19 @@
 2005-06-29  Christopher Faylor  <cgf@timesys.com>
 
+       * cygerrno.h: Make multi-inclusion safe.
+       * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Deal with EINTR.
+       * dcrt0.cc (dll_crt0_0): Accommodate init_console_handler argument
+       change.
+       * winsup.h: Ditto.
+       * fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
+       * exceptions.cc (init_console_handler): Ditto.  Ignore console events
+       if we're not attached to a terminal.
+       * fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
+       * wincap.cc: Implement has_null_console_handler_routine throughout.
+       * wincap.h: Ditto.
+
+2005-06-29  Christopher Faylor  <cgf@timesys.com>
+
        * autoload.cc (LoadDLLprime): Use a more descriptive name for autoload
        text sections.
        * cygwin.sc: Ditto.
index f1ecf35..48528f5 100644 (file)
@@ -8,6 +8,8 @@ This software is a copyrighted work licensed under the terms of the
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef _CYGERRNO_H
+#define _CYGERRNO_H
 #include <errno.h>
 
 void __stdcall seterrno_from_win_error (const char *file, int line, DWORD code) __attribute__ ((regparm(3)));
@@ -47,3 +49,4 @@ class save_errno
 
 extern const char *__sp_fn;
 extern int __sp_ln;
+#endif /*_CYGERRNO_H*/
index b119ba2..4154446 100644 (file)
@@ -636,7 +636,7 @@ dll_crt0_0 ()
   wincap.init ();
   initial_env ();
 
-  init_console_handler ();
+  init_console_handler (TRUE);
   init_global_security ();
   if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),
                       GetCurrentProcess (), &hMainProc, 0, FALSE,
index 6e44b5b..0e7a09f 100644 (file)
@@ -114,11 +114,24 @@ init_exceptions (exception_list *el)
   init_exception_handler (el, handle_exceptions);
 }
 
+BOOL WINAPI
+dummy_ctrl_c_handler (DWORD dwCtrlType)
+{
+  return TRUE;
+}
+
 void
-init_console_handler ()
+init_console_handler (BOOL install_handler)
 {
+  BOOL res;
   (void) SetConsoleCtrlHandler (ctrl_c_handler, FALSE);
-  if (!SetConsoleCtrlHandler (ctrl_c_handler, TRUE))
+  if (install_handler)
+    res = SetConsoleCtrlHandler (ctrl_c_handler, TRUE);
+  else if (wincap.has_null_console_handler_routine ())
+    res = SetConsoleCtrlHandler (NULL, TRUE);
+  else
+    res = SetConsoleCtrlHandler (dummy_ctrl_c_handler, TRUE);
+  if (!res)
     system_printf ("SetConsoleCtrlHandler failed, %E");
 }
 
index f54a08c..640d5dd 100644 (file)
@@ -21,6 +21,7 @@ details. */
 #include "pinfo.h"
 #include "tty.h"
 #include "sys/cygwin.h"
+#include "cygtls.h"
 
 /* Common functions shared by tty/console */
 
@@ -72,8 +73,30 @@ fhandler_termios::tcsetpgrp (const pid_t pgid)
       set_errno (EPERM);
       return -1;
     }
-  tc->setpgid (pgid);
-  return 0;
+  int res;
+  while (1)
+    {
+      res = bg_check (-SIGTTOU);
+
+      switch (res)
+       {
+       case bg_ok:
+         tc->setpgid (pgid);
+         init_console_handler (!!is_console ());
+         res = 0;
+         break;
+       case bg_signalled:
+         if (_my_tls.call_signal_handler ())
+           continue;
+         set_errno (EINTR);
+         /* fall through intentionally */
+       default:
+         res = -1;
+         break;
+       }
+      break;
+    }
+  return res;
 }
 
 int
index a31fe62..3d3cab5 100644 (file)
@@ -591,7 +591,7 @@ fhandler_tty_slave::open (int flags, mode_t)
                                // stuff fails
       termios_printf ("%d = AllocConsole (), %E", b);
       if (b)
-       init_console_handler ();
+       init_console_handler (TRUE);
     }
 
   // FIXME: Do this better someday
index 0d04047..a062c2a 100644 (file)
@@ -58,7 +58,8 @@ static NO_COPY wincaps wincap_unknown = {
   start_proc_suspended:true,
   has_extended_priority_class:false,
   has_guid_volumes:false,
-  detect_win16_exe:true
+  detect_win16_exe:true,
+  has_null_console_handler_routine:false
 };
 
 static NO_COPY wincaps wincap_95 = {
@@ -108,7 +109,8 @@ static NO_COPY wincaps wincap_95 = {
   start_proc_suspended:true,
   has_extended_priority_class:false,
   has_guid_volumes:false,
-  detect_win16_exe:true
+  detect_win16_exe:true,
+  has_null_console_handler_routine:false
 };
 
 static NO_COPY wincaps wincap_95osr2 = {
@@ -158,7 +160,8 @@ static NO_COPY wincaps wincap_95osr2 = {
   start_proc_suspended:true,
   has_extended_priority_class:false,
   has_guid_volumes:false,
-  detect_win16_exe:true
+  detect_win16_exe:true,
+  has_null_console_handler_routine:false
 };
 
 static NO_COPY wincaps wincap_98 = {
@@ -208,7 +211,8 @@ static NO_COPY wincaps wincap_98 = {
   start_proc_suspended:true,
   has_extended_priority_class:false,
   has_guid_volumes:false,
-  detect_win16_exe:true
+  detect_win16_exe:true,
+  has_null_console_handler_routine:false
 };
 
 static NO_COPY wincaps wincap_98se = {
@@ -258,7 +262,8 @@ static NO_COPY wincaps wincap_98se = {
   start_proc_suspended:true,
   has_extended_priority_class:false,
   has_guid_volumes:false,
-  detect_win16_exe:true
+  detect_win16_exe:true,
+  has_null_console_handler_routine:false
 };
 
 static NO_COPY wincaps wincap_me = {
@@ -308,7 +313,8 @@ static NO_COPY wincaps wincap_me = {
   start_proc_suspended:true,
   has_extended_priority_class:false,
   has_guid_volumes:false,
-  detect_win16_exe:true
+  detect_win16_exe:true,
+  has_null_console_handler_routine:false
 };
 
 static NO_COPY wincaps wincap_nt3 = {
@@ -358,7 +364,8 @@ static NO_COPY wincaps wincap_nt3 = {
   start_proc_suspended:false,
   has_extended_priority_class:false,
   has_guid_volumes:false,
-  detect_win16_exe:false
+  detect_win16_exe:false,
+  has_null_console_handler_routine:true
 };
 
 static NO_COPY wincaps wincap_nt4 = {
@@ -408,7 +415,8 @@ static NO_COPY wincaps wincap_nt4 = {
   start_proc_suspended:false,
   has_extended_priority_class:false,
   has_guid_volumes:false,
-  detect_win16_exe:false
+  detect_win16_exe:false,
+  has_null_console_handler_routine:true
 };
 
 static NO_COPY wincaps wincap_nt4sp4 = {
@@ -458,7 +466,8 @@ static NO_COPY wincaps wincap_nt4sp4 = {
   start_proc_suspended:false,
   has_extended_priority_class:false,
   has_guid_volumes:false,
-  detect_win16_exe:false
+  detect_win16_exe:false,
+  has_null_console_handler_routine:true
 };
 
 static NO_COPY wincaps wincap_2000 = {
@@ -508,7 +517,8 @@ static NO_COPY wincaps wincap_2000 = {
   start_proc_suspended:false,
   has_extended_priority_class:true,
   has_guid_volumes:true,
-  detect_win16_exe:false
+  detect_win16_exe:false,
+  has_null_console_handler_routine:true
 };
 
 static NO_COPY wincaps wincap_xp = {
@@ -558,7 +568,8 @@ static NO_COPY wincaps wincap_xp = {
   start_proc_suspended:false,
   has_extended_priority_class:true,
   has_guid_volumes:true,
-  detect_win16_exe:false
+  detect_win16_exe:false,
+  has_null_console_handler_routine:true
 };
 
 static NO_COPY wincaps wincap_2003 = {
@@ -608,7 +619,8 @@ static NO_COPY wincaps wincap_2003 = {
   start_proc_suspended:false,
   has_extended_priority_class:true,
   has_guid_volumes:true,
-  detect_win16_exe:false
+  detect_win16_exe:false,
+  has_null_console_handler_routine:true
 };
 
 wincapc wincap;
index abb801d..4f41065 100644 (file)
@@ -60,6 +60,7 @@ struct wincaps
   unsigned has_extended_priority_class                 : 1;
   unsigned has_guid_volumes                            : 1;
   unsigned detect_win16_exe                            : 1;
+  unsigned has_null_console_handler_routine            : 1;
 };
 
 class wincapc
@@ -124,6 +125,7 @@ public:
   bool IMPLEMENT (has_extended_priority_class)
   bool IMPLEMENT (has_guid_volumes)
   bool IMPLEMENT (detect_win16_exe)
+  bool IMPLEMENT (has_null_console_handler_routine)
 
 #undef IMPLEMENT
 };
index 2cc4c0c..fc9e9ec 100644 (file)
@@ -263,7 +263,7 @@ void __stdcall time_as_timestruc_t (timestruc_t *);
 void __stdcall timeval_to_filetime (const struct timeval *, FILETIME *);
 
 void __stdcall set_console_title (char *);
-void init_console_handler ();
+void init_console_handler (BOOL);
 void init_global_security ();
 
 int __stdcall check_null_str (const char *name) __attribute__ ((regparm(1)));