diff options
author | Christopher Faylor <me@cgf.cx> | 2003-12-08 09:27:05 +0300 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-12-08 09:27:05 +0300 |
commit | da915a3aa6868a0815616ff4ba7904081968de23 (patch) | |
tree | 201a8d77e87c0102c994d264f492e87b1e65efaf /winsup/cygwin | |
parent | 1b11f4fd72fd34daa11edbd6bed62547c8d2dfda (diff) |
* fhandler.h (fhandler_tty_slave::ttyname): Use name from pc since it is
guaranteed to be accurate.
* fhandler_tty.cc (fhandler_tty_slave::open): Increment open_fhs appropriate
when copying ctty.
(fhandler_tty_slave::close): Remove special case handling for exit_state. Use
ctty < 0 check instead.
(fhandler_tty_common::close): Set io_handle to NULL after closing.
* syscalls.cc (close_all_files): Specifically close cygheap->ctty, if
appropriate.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 12 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 5 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 6 |
4 files changed, 23 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index fb38a8208..63904fa4b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,15 @@ +2003-12-08 Christopher Faylor <cgf@redhat.com> + + * fhandler.h (fhandler_tty_slave::ttyname): Use name from pc since it + is guaranteed to be accurate. + * fhandler_tty.cc (fhandler_tty_slave::open): Increment open_fhs + appropriate when copying ctty. + (fhandler_tty_slave::close): Remove special case handling for + exit_state. Use ctty < 0 check instead. + (fhandler_tty_common::close): Set io_handle to NULL after closing. + * syscalls.cc (close_all_files): Specifically close cygheap->ctty, if + appropriate. + 2003-12-07 Christopher Faylor <cgf@redhat.com> * spawn.cc (spawn_guts): Change type back to 'int' after erroneous diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index d9212fe60..6014325b4 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -919,6 +919,7 @@ class fhandler_tty_slave: public fhandler_tty_common select_record *select_read (select_record *s); int cygserver_attach_tty (HANDLE*, HANDLE*); int get_unit () __attribute__ ((regparm (1))); + virtual char const *ttyname () { return pc.dev.name; } }; class fhandler_pty_master: public fhandler_tty_common diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index c5718a380..3cea6b9d0 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -454,6 +454,7 @@ fhandler_tty_slave::open (int flags, mode_t) else { *this = cygheap->ctty; + fhandler_console::open_fhs++; termios_printf ("copied tty fhandler from cygheap"); return 1; } @@ -601,7 +602,7 @@ fhandler_tty_slave::close () if (!--fhandler_console::open_fhs && myself->ctty == -1) FreeConsole (); termios_printf ("decremented open_fhs %d", fhandler_console::open_fhs); - if (!exit_state && get_io_handle () == cygheap->ctty.get_io_handle ()) + if (myself->ctty >= 0 && get_io_handle () == cygheap->ctty.get_io_handle ()) return 1; return fhandler_tty_common::close (); } @@ -1173,6 +1174,8 @@ fhandler_tty_common::close () if (!ForceCloseHandle1 (get_output_handle (), to_pty)) termios_printf ("CloseHandle (get_output_handle ()<%p>), %E", get_output_handle ()); + set_io_handle (NULL); + inuse = NULL; termios_printf ("tty%d <%p,%p> closed", get_unit (), get_handle (), get_output_handle ()); return 0; diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index c857ed487..268c34f46 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -97,6 +97,12 @@ close_all_files (void) cygheap->fdtab.release (i); } + if (cygheap->ctty.get_io_handle ()) + { + myself->ctty = -1; + cygheap->ctty.close (); + } + ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "close_all_files"); user_shared->delqueue.process_queue (); } |