From 1ada56d8e9a6d82ba5304fd17df078222072a9bf Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 2 Mar 2003 18:57:51 +0000 Subject: merge from trunk --- winsup/cygwin/ChangeLog | 25 ++++++++++++++++++++++++- winsup/cygwin/dll_init.cc | 5 ----- winsup/cygwin/dtable.cc | 17 ++--------------- winsup/cygwin/dtable.h | 9 +-------- winsup/cygwin/fhandler.h | 1 + winsup/cygwin/fhandler_console.cc | 7 +++++++ winsup/cygwin/syscalls.cc | 23 ++--------------------- winsup/cygwin/winsup.h | 1 - 8 files changed, 37 insertions(+), 51 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e2afc3d7ac1..5c5d53462f3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,26 @@ +2003-03-02 Christopher Faylor + + * dll_init.cc (dll_list::load_after_fork): Don't revert to LoadLibrary + if LoadLibraryEx fails. + * dtable.cc (dtable::dec_console_fds): Eliminate. + (dtable::release): Don't treat console specially. + (dtable::build_fhandler): Ditto. + * dtable.h (console_fds): Eliminate. + (dtable::dec_console_fds): Eliminate. + (dtable::inc_console_fds): Eliminate. + * fhandler.h (fhandler_console::open_fhs): New static element. + * fhandler_console.cc (fhandler_console::open): Increment open_fs. + (fhandler_console::close): Call FreeConsole if no more open consoles + and ctty is not associated with the console. + * syscalls.cc (setsid): Simplify check for when to call FreeConsole. + (check_pty_fds): Eliminate definition. + * winsup.h (check_pty_fds): Eliminate declaration. + +2003-03-02 Christopher Faylor + + * dll_init.cc (dll_list::load_after_fork): Fix typo where result of + LoadLibrary was ignored. + 2003-03-01 Corinna Vinschen * fhandler_socket.cc (fhandler_socket::bind): Open and write socket @@ -166,7 +189,7 @@ 2003-02-16 Christopher Faylor - * cygwin.din: Export all appropriate newlibc libm functions. Sort. + * cygwin.din: Export all appropriate newlib libm functions. Sort. * include/cygwin/version.h: Bump API minor number. 2003-02-15 Christopher Faylor diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index bd2b2af65d4..4e5491947d2 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -307,11 +307,6 @@ dll_list::load_after_fork (HANDLE parent, dll *first) bool unload = true; HMODULE h = LoadLibraryEx (d.name, NULL, DONT_RESOLVE_DLL_REFERENCES); - if (!h) - { - unload = false; - LoadLibrary (d.name); - } if (!h) system_printf ("can't reload %s", d.name); /* See if DLL will load in proper place. If so, free it and reload diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 1b21033fddb..de2570bcaef 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -57,14 +57,6 @@ set_std_handle (int fd) SetStdHandle (std_consts[fd], cygheap->fdtab[fd]->get_output_handle ()); } -void -dtable::dec_console_fds () -{ - if (console_fds > 0 && !--console_fds && - myself->ctty != TTY_CONSOLE && !check_pty_fds()) - FreeConsole (); -} - int dtable::extend (int howmuch) { @@ -190,9 +182,6 @@ dtable::release (int fd) case FH_SOCKET: dec_need_fixup_before (); break; - case FH_CONSOLE: - dec_console_fds (); - break; } delete fds[fd]; fds[fd] = NULL; @@ -369,8 +358,7 @@ build_fh_pc (path_conv& pc) case FH_CONSOLE: case FH_CONIN: case FH_CONOUT: - if ((fh = cnew (fhandler_console) ())) - cygheap->fdtab.inc_console_fds (); + fh = cnew (fhandler_console) (); break; case FH_CYGDRIVE: fh = cnew (fhandler_cygdrive) (); @@ -435,8 +423,7 @@ build_fh_pc (path_conv& pc) switch (newdev) { case FH_CONSOLE: - if ((fh = cnew (fhandler_console) ())) - cygheap->fdtab.inc_console_fds (); + fh = cnew (fhandler_console) (); break; case FH_TTYS: fh = cnew (fhandler_tty_slave) (); diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h index f1f0d456c3d..4003df0a9f5 100644 --- a/winsup/cygwin/dtable.h +++ b/winsup/cygwin/dtable.h @@ -23,11 +23,10 @@ class dtable fhandler_base **fds_on_hold; int first_fd_for_open; int cnt_need_fixup_before; - int console_fds; public: size_t size; - dtable () : first_fd_for_open(3), cnt_need_fixup_before(0), console_fds(0) {} + dtable () : first_fd_for_open(3), cnt_need_fixup_before(0) {} void init () {first_fd_for_open = 3;} void dec_need_fixup_before () @@ -37,12 +36,6 @@ public: BOOL need_fixup_before () { return cnt_need_fixup_before > 0; } - void dec_console_fds (); - void inc_console_fds () - { console_fds++; } - BOOL has_console_fds () - { return console_fds > 0; } - int vfork_child_dup (); void vfork_parent_restore (); void vfork_child_fixup (); diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 477c89045ff..930c680d373 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -804,6 +804,7 @@ class fhandler_console: public fhandler_termios void set_cursor_maybe (); public: + static int open_fhs; fhandler_console (); diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index df8e940054f..5b220f6fd28 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -89,6 +89,8 @@ static console_state NO_COPY *shared_console_info; dev_console NO_COPY *fhandler_console::dev_state; +int NO_COPY fhandler_console::open_fhs; + /* Allocate and initialize the shared record for the current console. Returns a pointer to shared_console_info. */ tty_min * @@ -630,6 +632,8 @@ fhandler_console::open (int flags, mode_t) TTYCLEARF (RSTCONS); set_open_status (); + open_fhs++; + debug_printf ("incremented open_fhs, now %d", open_fhs); debug_printf ("opened conin$ %p, conout$ %p", get_io_handle (), get_output_handle ()); @@ -643,6 +647,9 @@ fhandler_console::close (void) CloseHandle (get_output_handle ()); set_io_handle (NULL); set_output_handle (NULL); + if (--open_fhs <= 0 && myself->ctty != FH_CONSOLE) + FreeConsole (); + debug_printf ("decremented open_fhs, now %d", open_fhs); return 0; } diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index d0846c6ab6b..1ec38d09fd8 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -83,23 +83,6 @@ close_all_files (void) cygwin_shared->delqueue.process_queue (); } -BOOL __stdcall -check_pty_fds (void) -{ - int res = FALSE; - SetResourceLock (LOCK_FD_LIST, WRITE_LOCK, "check_pty_fds"); - fhandler_base *fh; - for (int i = 0; i < (int) cygheap->fdtab.size; i++) - if ((fh = cygheap->fdtab[i]) != NULL && - (fh->get_device () == FH_TTYS || fh->get_device () == FH_PTYM)) - { - res = TRUE; - break; - } - ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK, "check_pty_fds"); - return res; -} - int dup (int fd) { @@ -308,11 +291,9 @@ setsid (void) if (myself->pgid != myself->pid) { - if (myself->ctty == TTY_CONSOLE - && !cygheap->fdtab.has_console_fds () - && !check_pty_fds ()) - FreeConsole (); myself->ctty = -1; + if (fhandler_console::open_fhs <= 0) + FreeConsole (); myself->sid = getpid (); myself->pgid = getpid (); syscall_printf ("sid %d, pgid %d, ctty %d", myself->sid, myself->pgid, myself->ctty); diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index fc6a06fd922..3504265856c 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -164,7 +164,6 @@ void events_init (void); void events_terminate (void); void __stdcall close_all_files (void); -BOOL __stdcall check_pty_fds (void); /* Invisible window initialization/termination. */ HWND __stdcall gethwnd (void); -- cgit v1.2.1