* 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.
This commit is contained in:
Christopher Faylor 2003-03-02 18:37:17 +00:00
parent 3efc65f7df
commit 8b19b43d00
8 changed files with 30 additions and 48 deletions

View File

@ -1,3 +1,21 @@
2003-03-02 Christopher Faylor <cgf@redhat.com>
* 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 <cgf@redhat.com> 2003-03-02 Christopher Faylor <cgf@redhat.com>
* dll_init.cc (dll_list::load_after_fork): Fix typo where result of * dll_init.cc (dll_list::load_after_fork): Fix typo where result of

View File

@ -307,11 +307,6 @@ dll_list::load_after_fork (HANDLE parent, dll *first)
bool unload = true; bool unload = true;
HMODULE h = LoadLibraryEx (d.name, NULL, DONT_RESOLVE_DLL_REFERENCES); HMODULE h = LoadLibraryEx (d.name, NULL, DONT_RESOLVE_DLL_REFERENCES);
if (!h)
{
unload = false;
h = LoadLibrary (d.name);
}
if (!h) if (!h)
system_printf ("can't reload %s", d.name); system_printf ("can't reload %s", d.name);
/* See if DLL will load in proper place. If so, free it and reload /* See if DLL will load in proper place. If so, free it and reload

View File

@ -57,14 +57,6 @@ set_std_handle (int fd)
SetStdHandle (std_consts[fd], cygheap->fdtab[fd]->get_output_handle ()); 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 int
dtable::extend (int howmuch) dtable::extend (int howmuch)
{ {
@ -190,9 +182,6 @@ dtable::release (int fd)
case FH_SOCKET: case FH_SOCKET:
dec_need_fixup_before (); dec_need_fixup_before ();
break; break;
case FH_CONSOLE:
dec_console_fds ();
break;
} }
delete fds[fd]; delete fds[fd];
fds[fd] = NULL; fds[fd] = NULL;
@ -334,8 +323,7 @@ dtable::build_fhandler (int fd, DWORD dev, char *unix_name,
case FH_CONSOLE: case FH_CONSOLE:
case FH_CONIN: case FH_CONIN:
case FH_CONOUT: case FH_CONOUT:
if ((fh = cnew (fhandler_console) ())) fh = cnew (fhandler_console) ();
inc_console_fds ();
break; break;
case FH_PTYM: case FH_PTYM:
fh = cnew (fhandler_pty_master) (); fh = cnew (fhandler_pty_master) ();

View File

@ -20,11 +20,10 @@ class dtable
fhandler_base **fds_on_hold; fhandler_base **fds_on_hold;
int first_fd_for_open; int first_fd_for_open;
int cnt_need_fixup_before; int cnt_need_fixup_before;
int console_fds;
public: public:
size_t size; 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 init () {first_fd_for_open = 3;}
void dec_need_fixup_before () void dec_need_fixup_before ()
@ -34,12 +33,6 @@ public:
BOOL need_fixup_before () BOOL need_fixup_before ()
{ return cnt_need_fixup_before > 0; } { 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 (); int vfork_child_dup ();
void vfork_parent_restore (); void vfork_parent_restore ();
void vfork_child_fixup (); void vfork_child_fixup ();

View File

@ -819,6 +819,7 @@ class fhandler_console: public fhandler_termios
void set_cursor_maybe (); void set_cursor_maybe ();
public: public:
static int open_fhs;
fhandler_console (); fhandler_console ();

View File

@ -89,6 +89,8 @@ static console_state NO_COPY *shared_console_info;
dev_console NO_COPY *fhandler_console::dev_state; 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. /* Allocate and initialize the shared record for the current console.
Returns a pointer to shared_console_info. */ Returns a pointer to shared_console_info. */
tty_min * tty_min *
@ -630,6 +632,8 @@ fhandler_console::open (path_conv *, int flags, mode_t)
TTYCLEARF (RSTCONS); TTYCLEARF (RSTCONS);
set_open_status (); set_open_status ();
open_fhs++;
debug_printf ("incremented open_fhs, now %d", open_fhs);
debug_printf ("opened conin$ %p, conout$ %p", debug_printf ("opened conin$ %p, conout$ %p",
get_io_handle (), get_output_handle ()); get_io_handle (), get_output_handle ());
@ -643,6 +647,9 @@ fhandler_console::close (void)
CloseHandle (get_output_handle ()); CloseHandle (get_output_handle ());
set_io_handle (NULL); set_io_handle (NULL);
set_output_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; return 0;
} }

View File

@ -77,23 +77,6 @@ close_all_files (void)
cygwin_shared->delqueue.process_queue (); 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 int
dup (int fd) dup (int fd)
{ {
@ -302,11 +285,9 @@ setsid (void)
if (myself->pgid != myself->pid) if (myself->pgid != myself->pid)
{ {
if (myself->ctty == TTY_CONSOLE
&& !cygheap->fdtab.has_console_fds ()
&& !check_pty_fds ())
FreeConsole ();
myself->ctty = -1; myself->ctty = -1;
if (fhandler_console::open_fhs <= 0)
FreeConsole ();
myself->sid = getpid (); myself->sid = getpid ();
myself->pgid = getpid (); myself->pgid = getpid ();
syscall_printf ("sid %d, pgid %d, ctty %d", myself->sid, myself->pgid, myself->ctty); syscall_printf ("sid %d, pgid %d, ctty %d", myself->sid, myself->pgid, myself->ctty);

View File

@ -164,7 +164,6 @@ void events_init (void);
void events_terminate (void); void events_terminate (void);
void __stdcall close_all_files (void); void __stdcall close_all_files (void);
BOOL __stdcall check_pty_fds (void);
/* Invisible window initialization/termination. */ /* Invisible window initialization/termination. */
HWND __stdcall gethwnd (void); HWND __stdcall gethwnd (void);