diff options
author | Christopher Faylor <me@cgf.cx> | 2003-12-27 01:59:29 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-12-27 01:59:29 +0000 |
commit | 1df3fbe2db6c972b8e8bdc31b473718a39bf88fa (patch) | |
tree | 12bfaf8a6f6d1d05ed0551f0202ca4e31288a5f6 | |
parent | 56b5feb639f51385da560289e1c1e65512fb3f67 (diff) | |
download | newlib-1df3fbe2db6c972b8e8bdc31b473718a39bf88fa.zip newlib-1df3fbe2db6c972b8e8bdc31b473718a39bf88fa.tar.gz newlib-1df3fbe2db6c972b8e8bdc31b473718a39bf88fa.tar.bz2 |
* fhandler.h (fhandler_tty_master::fixup_after_fork): Remove declaration.
(fhandler_tty_master::fixup_after_exec): Ditto.
* fhandler_tty.cc (fhandler_tty_master::init): Fix so that children do not
inherit master tty handles.
(fhandler_tty_master::fixup_after_fork): Remove, since it was never used.
(fhandler_tty_master::fixup_after_exec): Ditto.
* pinfo.cc (_pinfo::set_ctty): Increment open_fhs when ctty is set.
* cygheap.cc (cygheap_init): Ditto.
* syscalls.cc (setsid): *Always* call close on opened ctty since the archetype
is associated with the ctty and it counts as an opened handle.
* tty.cc (tty::common_init): Don't protect input/output mutex since it confuses
subsequent fork/execs when CYGWIN=tty.
-rw-r--r-- | winsup/cygwin/ChangeLog | 18 | ||||
-rw-r--r-- | winsup/cygwin/cygheap.cc | 7 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.h | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 15 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 3 | ||||
-rw-r--r-- | winsup/cygwin/tty.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/tty.h | 2 |
8 files changed, 34 insertions, 23 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a357ef4..a63ee6e 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,23 @@ 2003-12-26 Christopher Faylor <cgf@redhat.com> + * fhandler.h (fhandler_tty_master::fixup_after_fork): Remove + declaration. + (fhandler_tty_master::fixup_after_exec): Ditto. + * fhandler_tty.cc (fhandler_tty_master::init): Fix so that children do + not inherit master tty handles. + (fhandler_tty_master::fixup_after_fork): Remove, since it was never + used. + (fhandler_tty_master::fixup_after_exec): Ditto. + * pinfo.cc (_pinfo::set_ctty): Increment open_fhs when ctty is set. + * cygheap.cc (cygheap_init): Ditto. + * syscalls.cc (setsid): *Always* call close on opened ctty since the + archetype is associated with the ctty and it counts as an opened + handle. + * tty.cc (tty::common_init): Don't protect input/output mutex since it + confuses subsequent fork/execs when CYGWIN=tty. + +2003-12-26 Christopher Faylor <cgf@redhat.com> + * exceptions.cc (try_to_debug): Fix off-by-one problem when resetting environment variable after error_start detected. diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 6859e43..16a95f4 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -212,6 +212,13 @@ cygheap_init () && (set_process_privilege (SE_CREATE_GLOBAL_NAME, true) >= 0 || GetLastError () == ERROR_NO_SUCH_PRIVILEGE) ? "Global\\" : ""); + if (cygheap->ctty) + { + fhandler_console::open_fhs++; + debug_printf ("tty%d, open_fhs %d, arch usecount %d", + cygheap->ctty->get_ttyp ()->ntty, + fhandler_console::open_fhs, cygheap->ctty->usecount); + } } /* Copyright (C) 1997, 2000 DJ Delorie */ diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 3e0f3fb..5cbf387 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -890,7 +890,7 @@ class fhandler_tty_common: public fhandler_termios virtual int dup (fhandler_base *child); - tty *get_ttyp () { return (tty *)tc; } + tty *get_ttyp () { return (tty *) tc; } int close (); void set_close_on_exec (int val); @@ -969,8 +969,6 @@ class fhandler_tty_master: public fhandler_pty_master int init (); int init_console (); void set_winsize (bool); - void fixup_after_fork (HANDLE parent); - void fixup_after_exec (HANDLE); bool is_slow () {return 1;} }; diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index d5cbcad..ff1d48f 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -78,6 +78,7 @@ fhandler_tty_master::init () set_winsize (false); inuse = get_ttyp ()->create_inuse (TTY_MASTER_ALIVE); + set_close_on_exec (true); cygthread *h; h = new cygthread (process_input, cygself, "ttyin"); @@ -1402,20 +1403,6 @@ fhandler_pty_master::set_close_on_exec (int val) } } -void -fhandler_tty_master::fixup_after_fork (HANDLE child) -{ - fhandler_pty_master::fixup_after_fork (child); - console->fixup_after_fork (child); -} - -void -fhandler_tty_master::fixup_after_exec (HANDLE) -{ - console->close (); - init_console (); -} - int fhandler_tty_master::init_console () { diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 581e2fb..61c74db 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -293,7 +293,9 @@ _pinfo::set_ctty (tty_min *tc, int flags, fhandler_tty_slave *arch) if (arch) { arch->usecount++; - debug_printf ("arch usecount for tty%d is %d", tc->ntty, arch->usecount); + fhandler_console::open_fhs++; + debug_printf ("tty%d, open_fhs %d, arch usecount %d", tc->ntty, + fhandler_console::open_fhs, arch->usecount); } } } diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index ab8aeea..4a8cade 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -335,8 +335,7 @@ setsid (void) myself->pgid, myself->ctty, fhandler_console::open_fhs); if (cygheap->ctty) { - if (cygheap->ctty->usecount == 1) - cygheap->ctty->close (); + cygheap->ctty->close (); cygheap->ctty = NULL; } return myself->sid; diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc index 07c7a0a..7e3aeb9 100644 --- a/winsup/cygwin/tty.cc +++ b/winsup/cygwin/tty.cc @@ -457,8 +457,8 @@ tty::common_init (fhandler_pty_master *ptym) return false; } - ProtectHandle1INH (ptym->output_mutex, output_mutex); - ProtectHandle1INH (ptym->input_mutex, input_mutex); + // /* screws up tty master */ ProtectHandle1INH (ptym->output_mutex, output_mutex); + // /* screws up tty master */ ProtectHandle1INH (ptym->input_mutex, input_mutex); winsize.ws_col = 80; winsize.ws_row = 25; diff --git a/winsup/cygwin/tty.h b/winsup/cygwin/tty.h index 8153aaf..c5d0152 100644 --- a/winsup/cygwin/tty.h +++ b/winsup/cygwin/tty.h @@ -87,7 +87,7 @@ class fhandler_pty_master; class tty: public tty_min { HANDLE get_event (const char *fmt, BOOL manual_reset = FALSE) - __attribute__ ((regparm (2))); + __attribute__ ((regparm (3))); public: HWND hwnd; /* Console window handle tty belongs to */ |