Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-06-30 06:52:14 +0400
committerChristopher Faylor <me@cgf.cx>2005-06-30 06:52:14 +0400
commit5b3e1f7358338fa4fe7223fb34df9a06fda7e97c (patch)
tree8627ea790d932d24c96ba83d8cfac61d59560126
parentd573a471af3908faf346e61d51e04944ca33a38e (diff)
* 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.
-rw-r--r--winsup/cygwin/ChangeLog14
-rw-r--r--winsup/cygwin/cygerrno.h3
-rw-r--r--winsup/cygwin/dcrt0.cc2
-rw-r--r--winsup/cygwin/exceptions.cc17
-rw-r--r--winsup/cygwin/fhandler_termios.cc27
-rw-r--r--winsup/cygwin/fhandler_tty.cc2
-rw-r--r--winsup/cygwin/wincap.cc36
-rw-r--r--winsup/cygwin/wincap.h2
-rw-r--r--winsup/cygwin/winsup.h2
9 files changed, 86 insertions, 19 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 2b6a105f1..78d4fd7c5 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 f1ecf35fd..48528f520 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 b119ba201..415444682 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 6e44b5b21..0e7a09fdf 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 f54a08c0e..640d5dd5e 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 a31fe6244..3d3cab5a2 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 0d0404702..a062c2ac2 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 abb801da2..4f41065d0 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 2cc4c0ce0..fc9e9ec22 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)));