* exceptions.cc (ctrl_c_handler): Send SIGHUP when events occur only if there

is a tty associated with the process.  Send SIGHUP on CTRL_LOGOFF_EVENT.
* fhandler_tty.cc (fhandler_tty_slave::open): Adjust console open handle
counter regardless of whether this is a pty or tty.
(fhandler_tty_slave::open): Ditto.
(fhandler_tty_slave::dup): Ditto.
(fhandler_tty_common::set_close_on_exec): Ditto.
(fhandler_tty_master::init_console): Decrement console open handle counter
after init since it will now be handled by all tty open.
* syscalls.cc (setsid): Rework debugging output slightly.
This commit is contained in:
Christopher Faylor
2003-07-26 04:53:59 +00:00
parent ddb6762155
commit df04ae29b2
14 changed files with 231 additions and 223 deletions

View File

@@ -555,25 +555,22 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
set_output_handle (to_master_local);
set_open_status ();
if (!output_done_event)
if (fhandler_console::open_fhs++ == 0 && !output_done_event
&& wincap.pty_needs_alloc_console ())
{
if (fhandler_console::open_fhs++ == 0
&& wincap.pty_needs_alloc_console ())
BOOL b;
HWINSTA h = CreateWindowStation (NULL, 0, GENERIC_READ | GENERIC_WRITE, &sec_none_nih);
termios_printf ("CreateWindowStation %p, %E", h);
if (h)
{
BOOL b;
HWINSTA h = CreateWindowStation (NULL, 0, GENERIC_READ | GENERIC_WRITE, &sec_none_nih);
termios_printf ("CreateWindowStation %p, %E", h);
if (h)
{
b = SetProcessWindowStation (h);
termios_printf ("SetProcessWindowStation %d, %E", b);
}
b = AllocConsole (); // will cause flashing if workstation
// stuff fails
termios_printf ("%d = AllocConsole ()", b);
b = SetProcessWindowStation (h);
termios_printf ("SetProcessWindowStation %d, %E", b);
}
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
b = AllocConsole (); // will cause flashing if workstation
// stuff fails
termios_printf ("%d = AllocConsole ()", b);
}
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
termios_printf ("tty%d opened", ttynum);
return 1;
@@ -582,12 +579,9 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
int
fhandler_tty_slave::close ()
{
if (!output_done_event)
{
if (!--fhandler_console::open_fhs && myself->ctty == -1)
FreeConsole ();
termios_printf ("decremented open_fhs %d", fhandler_console::open_fhs);
}
if (!--fhandler_console::open_fhs && myself->ctty == -1)
FreeConsole ();
termios_printf ("decremented open_fhs %d", fhandler_console::open_fhs);
return fhandler_tty_common::close ();
}
@@ -855,11 +849,8 @@ fhandler_tty_slave::read (void *ptr, size_t& len)
int
fhandler_tty_slave::dup (fhandler_base *child)
{
if (!output_done_event)
{
fhandler_console::open_fhs++;
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
}
fhandler_console::open_fhs++;
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
return fhandler_tty_common::dup (child);
}
@@ -1253,11 +1244,8 @@ fhandler_tty_common::set_close_on_exec (int val)
void
fhandler_tty_slave::fixup_after_fork (HANDLE parent)
{
if (!output_done_event)
{
fhandler_console::open_fhs++;
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
}
fhandler_console::open_fhs++;
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
fhandler_tty_common::fixup_after_fork (parent);
}
@@ -1317,6 +1305,7 @@ fhandler_tty_master::init_console ()
return -1;
console->init (INVALID_HANDLE_VALUE, GENERIC_READ | GENERIC_WRITE, O_BINARY);
fhandler_console::open_fhs--; /* handled when individual fds are opened */
console->set_r_no_interrupt (1);
return 0;
}