* cygheap.h (init_cygheap::manage_console_count): Declare new function.
(init_cygheap::console_count): Renamed from open_fhs. Make private. * cygheap.cc (init_cygheap::manage_console_count): Define new function. * dtable.cc (dtable::fixup_after_exec): Always call fixup_after_exec on elements of fd even when they are about to be closed. * fhandler.h (report_tty_counts): Remove open_fhs from debugging output. * fhandler_console.cc (fhandler_console::open): Use manage_console_count rather than manipulating count directly. (fhandler_console::close): Ditto. (fhandler_console::fixup_after_fork): Ditto. (fhandler_console::fixup_after_exec): Ditto. Don't close handles if close_on_exec. * fhandler_tty.cc (fhandler_tty_slave::open): Use manage_console_count() rather than manipulating count directly. Reflect change in arguments to report_tty_counts(). (fhandler_tty_slave::close): Ditto for both. (fhandler_tty_slave::dup): Ditto for both. (fhandler_tty_slave::ioctl): Use myctty() rather than raw ctty #. (fhandler_tty_slave::fixup_after_fork): Reflect change in arguments to report_tty_counts(). (fhandler_tty_master::init_console): Use manage_console_count() rather than manipulating count directly. * fhandler_clipboard.cc (fhandler_dev_clipboard::fixup_after_exec): Don't perform any operations if close_on_exec. * fhandler_dsp.cc (fhandler_dev_dsp::fixup_after_exec): Ditto. * fhandler_raw.cc (fhandler_dev_raw::fixup_after_exec): Ditto. * fhandler_serial.cc (fhandler_serial::fixup_after_exec): Ditto. * pinfo.h (_pinfo::_ctty): Declare new function. (myctty): Declare new macro. (__ctty): Declare new macro. * pinfo.cc (_pinfo::_ctty): Define new function. (_pinfo::set_ctty): Use manage_console_count() rather than manipulating count directly. * signal.cc (kill_pgrp): Use myctty() and __ctty() macros rather than raw ctty #. * syscalls.cc (setsid): Ditto. Use manage_console_count() rather than manipulating count directly.
This commit is contained in:
@@ -457,7 +457,7 @@ fhandler_tty_slave::open (int flags, mode_t)
|
||||
*this = *(fhandler_tty_slave *) arch;
|
||||
termios_printf ("copied tty fhandler archetype");
|
||||
set_flags ((flags & ~O_TEXT) | O_BINARY);
|
||||
cygheap->open_fhs++;
|
||||
cygheap->manage_console_count ("fhandler_tty_slave::open<arch>", 1);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -576,7 +576,8 @@ fhandler_tty_slave::open (int flags, mode_t)
|
||||
set_output_handle (to_master_local);
|
||||
|
||||
set_open_status ();
|
||||
if (cygheap->open_fhs++ == 0 && !GetConsoleCP () && !output_done_event
|
||||
if (cygheap->manage_console_count ("fhandler_tty_slave::open", 1) == 1
|
||||
&& !GetConsoleCP () && !output_done_event
|
||||
&& wincap.pty_needs_alloc_console () && !GetProcessWindowStation ())
|
||||
{
|
||||
BOOL b;
|
||||
@@ -603,7 +604,7 @@ fhandler_tty_slave::open (int flags, mode_t)
|
||||
out:
|
||||
usecount = 0;
|
||||
archetype->usecount++;
|
||||
report_tty_counts (this, "opened", "incremented ", "");
|
||||
report_tty_counts (this, "opened", "");
|
||||
myself->set_ctty (get_ttyp (), flags, arch);
|
||||
|
||||
return 1;
|
||||
@@ -614,11 +615,10 @@ fhandler_tty_slave::close ()
|
||||
{
|
||||
if (!hExeced)
|
||||
{
|
||||
if (!--cygheap->open_fhs && myself->ctty == -1)
|
||||
FreeConsole ();
|
||||
cygheap->manage_console_count ("fhandler_tty_slave::close", -1);
|
||||
|
||||
archetype->usecount--;
|
||||
report_tty_counts (this, "closed", "decremented ", "");
|
||||
report_tty_counts (this, "closed", "");
|
||||
|
||||
if (archetype->usecount)
|
||||
{
|
||||
@@ -921,8 +921,8 @@ fhandler_tty_slave::dup (fhandler_base *child)
|
||||
*(fhandler_tty_slave *) child = *arch;
|
||||
child->usecount = 0;
|
||||
arch->usecount++;
|
||||
cygheap->open_fhs++;
|
||||
report_tty_counts (child, "duped", "incremented ", "");
|
||||
cygheap->manage_console_count ("fhandler_tty_slave::dup", 1);
|
||||
report_tty_counts (child, "duped", "");
|
||||
myself->set_ctty (get_ttyp (), openflags, arch);
|
||||
return 0;
|
||||
}
|
||||
@@ -1070,8 +1070,8 @@ fhandler_tty_slave::ioctl (unsigned int cmd, void *arg)
|
||||
&& myself->ctty == get_unit () && (get_ttyp ()->ti.c_lflag & TOSTOP))
|
||||
{
|
||||
/* background process */
|
||||
termios_printf ("bg ioctl pgid %d, tpgid %d, ctty %d",
|
||||
myself->pgid, get_ttyp ()->getpgid (), myself->ctty);
|
||||
termios_printf ("bg ioctl pgid %d, tpgid %d, %s", myself->pgid,
|
||||
get_ttyp ()->getpgid (), myctty ());
|
||||
raise (SIGTTOU);
|
||||
}
|
||||
|
||||
@@ -1389,7 +1389,7 @@ void
|
||||
fhandler_tty_slave::fixup_after_fork (HANDLE parent)
|
||||
{
|
||||
// fhandler_tty_common::fixup_after_fork (parent);
|
||||
report_tty_counts (this, "inherited", "", "");
|
||||
report_tty_counts (this, "inherited", "");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1434,7 +1434,7 @@ fhandler_tty_master::init_console ()
|
||||
return -1;
|
||||
|
||||
console->init (INVALID_HANDLE_VALUE, GENERIC_READ | GENERIC_WRITE, O_BINARY);
|
||||
cygheap->open_fhs--; /* handled when individual fds are opened */
|
||||
cygheap->manage_console_count ("fhandler_tty_master::init_console", -1, true);
|
||||
console->uninterruptible_io (true);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user