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>2002-08-02 06:10:24 +0400
committerChristopher Faylor <me@cgf.cx>2002-08-02 06:10:24 +0400
commit6b2a9a2fdf2a62475c7bb7ff3ef49eee5b82fa6e (patch)
tree11e02150f990347628c418296d1344740b7ac689 /winsup/cygwin/fhandler_tty.cc
parent8a19897f17594f47d2c4cc78bae466e9c54dc1e1 (diff)
* 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.
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r--winsup/cygwin/fhandler_tty.cc24
1 files changed, 11 insertions, 13 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 2ead75122..a7b7d814d 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -37,7 +37,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)
{
}
@@ -69,9 +69,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;
}
@@ -377,15 +376,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;
@@ -1186,6 +1183,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
@@ -1193,7 +1191,7 @@ fhandler_tty_master::fixup_after_exec (HANDLE)
{
console->close ();
init_console ();
- return;
+ output_thread = NULL; // It's unreachable now
}
int