diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 14 | ||||
-rw-r--r-- | winsup/cygwin/cygerrno.h | 3 | ||||
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 17 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_termios.cc | 27 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/wincap.cc | 36 | ||||
-rw-r--r-- | winsup/cygwin/wincap.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/winsup.h | 2 |
9 files changed, 86 insertions, 19 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 2b6a105..78d4fd7 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -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. diff --git a/winsup/cygwin/cygerrno.h b/winsup/cygwin/cygerrno.h index f1ecf35..48528f5 100644 --- a/winsup/cygwin/cygerrno.h +++ b/winsup/cygwin/cygerrno.h @@ -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*/ diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index b119ba2..4154446 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -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, diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 6e44b5b..0e7a09f 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -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"); } diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc index f54a08c..640d5dd 100644 --- a/winsup/cygwin/fhandler_termios.cc +++ b/winsup/cygwin/fhandler_termios.cc @@ -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 diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index a31fe62..3d3cab5 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -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 diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc index 0d04047..a062c2a 100644 --- a/winsup/cygwin/wincap.cc +++ b/winsup/cygwin/wincap.cc @@ -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; diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h index abb801d..4f41065 100644 --- a/winsup/cygwin/wincap.h +++ b/winsup/cygwin/wincap.h @@ -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 }; diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 2cc4c0c..fc9e9ec 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -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))); |