From 5fd6104d132c65614f004d8000876c1d8cba1bda Mon Sep 17 00:00:00 2001 From: scottc Date: Fri, 2 Aug 2002 02:23:44 +0000 Subject: Merged changes from HEAD --- winsup/cygwin/ChangeLog | 26 ++++++++++++++++++++++++++ winsup/cygwin/cygthread.cc | 7 +++++++ winsup/cygwin/cygthread.h | 1 + winsup/cygwin/fhandler.h | 3 ++- winsup/cygwin/fhandler_tty.cc | 24 +++++++++++------------- winsup/cygwin/syscalls.cc | 2 +- winsup/cygwin/tty.cc | 5 +++-- 7 files changed, 51 insertions(+), 17 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index fe46ff1959d..216d83b9b6d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,29 @@ +2002-08-01 Christopher Faylor + + * cygthread.cc (cygthread::exit_thread): Define new method. + * cygthread.h (cygthread::exit_thread): Declare new method. + * fhandler.h (fhandler_tty_master::hThread): Delete. + (fhandler_tty_master::output_thread): Define. + * fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Adjust + constructor. + (fhandler_tty_master::init): Use cygthread rather than handle. + (process_output): Use cygthread method to exit. + (fhandler_tty_master::fixup_after_fork): Set output_thread to NULL + after fork. + (fhandler_tty_master::fixup_after_exec): Set output_thread to NULL + after spawn/exec. + * tty.cc (tty_list::terminate): Detach from output_thread using + cygthread method. + +2002-08-01 Christopher Faylor + + * syscalls.cc (_link): Revert previous change and just always + dereference the oldpath. + +2002-08-01 Christopher Faylor + + * syscalls.cc (link): Properly deal with a link to a symlink. + 2002-08-01 Christopher Faylor * cygthread.cc: Remove cruft. diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc index 66abb7408df..a4f32472de1 100644 --- a/winsup/cygwin/cygthread.cc +++ b/winsup/cygwin/cygthread.cc @@ -147,6 +147,13 @@ HANDLE () return ev; } +void +cygthread::exit_thread () +{ + SetEvent (ev); + ExitThread (0); +} + void cygthread::detach () { diff --git a/winsup/cygwin/cygthread.h b/winsup/cygwin/cygthread.h index 67e9d591e60..b4f6cbe2fbd 100644 --- a/winsup/cygwin/cygthread.h +++ b/winsup/cygwin/cygthread.h @@ -27,4 +27,5 @@ class cygthread operator HANDLE (); static bool is (); void * operator new (size_t); + void exit_thread (); }; diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 17390bdc3e8..a338987d4f3 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -921,12 +921,13 @@ class fhandler_pty_master: public fhandler_tty_common bool hit_eof (); }; +class cygthread; class fhandler_tty_master: public fhandler_pty_master { public: /* Constructor */ fhandler_console *console; // device handler to perform real i/o. - HANDLE hThread; // process_output thread handle. + cygthread *output_thread; // process_output thread fhandler_tty_master (int unit); int init (int); diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 988d3914a93..9a32709fcd4 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -36,7 +36,7 @@ static DWORD WINAPI process_output (void *); // Output queue thread static DWORD WINAPI process_ioctl (void *); // Ioctl requests thread fhandler_tty_master::fhandler_tty_master (int unit) - : fhandler_pty_master (FH_TTYM, unit), console (NULL), hThread (NULL) + : fhandler_pty_master (FH_TTYM, unit), console (NULL), output_thread (NULL) { } @@ -68,9 +68,8 @@ fhandler_tty_master::init (int ntty) h = new cygthread (process_ioctl, NULL, "ttyioctl"); SetThreadPriority (*h, THREAD_PRIORITY_HIGHEST); - h = new cygthread (process_output, NULL, "ttyout"); - hThread = *h; - SetThreadPriority (h, THREAD_PRIORITY_HIGHEST); + output_thread = new cygthread (process_output, NULL, "ttyout"); + SetThreadPriority (*output_thread, THREAD_PRIORITY_HIGHEST); return 0; } @@ -376,15 +375,13 @@ process_output (void *) for (;;) { int n = tty_master->process_slave_output (buf, OUT_BUFFER_SIZE, 0); - if (n < 0) + if (n <= 0) { - termios_printf ("ReadFile %E"); - ExitThread (0); - } - if (n == 0) - { - /* End of file. */ - ExitThread (0); + if (n < 0) + termios_printf ("ReadFile %E"); + cygthread *t = tty_master->output_thread; + tty_master->output_thread = NULL; + t->exit_thread (); } n = tty_master->console->write ((void *) buf, (size_t) n); tty_master->get_ttyp ()->write_error = n == -1 ? get_errno () : 0; @@ -1171,6 +1168,7 @@ fhandler_tty_master::fixup_after_fork (HANDLE child) { this->fhandler_pty_master::fixup_after_fork (child); console->fixup_after_fork (child); + output_thread = NULL; // It's unreachable now } void @@ -1178,7 +1176,7 @@ fhandler_tty_master::fixup_after_exec (HANDLE) { console->close (); init_console (); - return; + output_thread = NULL; // It's unreachable now } int diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 4b2fc3d0738..4792744e026 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -615,8 +615,8 @@ _link (const char *a, const char *b) { int res = -1; sigframe thisframe (mainthread); + path_conv real_a (a, PC_SYM_FOLLOW | PC_FULL); path_conv real_b (b, PC_SYM_NOFOLLOW | PC_FULL); - path_conv real_a (a, PC_SYM_NOFOLLOW | PC_FULL); if (real_a.error) { diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc index c14a300d913..2a2995e5954 100644 --- a/winsup/cygwin/tty.cc +++ b/winsup/cygwin/tty.cc @@ -24,6 +24,7 @@ details. */ #include "pinfo.h" #include "cygwin/cygserver.h" #include "shared_info.h" +#include "cygthread.h" extern fhandler_tty_master *tty_master; @@ -143,8 +144,8 @@ tty_list::terminate (void) ForceCloseHandle1 (t->to_slave, to_pty); ForceCloseHandle1 (t->from_slave, from_pty); CloseHandle (tty_master->inuse); - // FIXME This should be using a cygthread object - WaitForSingleObject (tty_master->hThread, INFINITE); + if (tty_master->output_thread) + tty_master->output_thread->detach (); t->init (); char buf[20]; -- cgit v1.2.1