summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_tty.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-07-26 04:53:59 +0000
committerChristopher Faylor <me@cgf.cx>2003-07-26 04:53:59 +0000
commitdf04ae29b258b89bbd4991bd862a03ac56430e4e (patch)
treef853669603e469c7c37bc4c829a247b16958464f /winsup/cygwin/fhandler_tty.cc
parentddb67621550071ee1472cb114704af155d46365b (diff)
downloadcygnal-df04ae29b258b89bbd4991bd862a03ac56430e4e.tar.gz
cygnal-df04ae29b258b89bbd4991bd862a03ac56430e4e.tar.bz2
cygnal-df04ae29b258b89bbd4991bd862a03ac56430e4e.zip
* 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.
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r--winsup/cygwin/fhandler_tty.cc51
1 files changed, 20 insertions, 31 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 6e3a93364..44eb21e6b 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -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;
}