* 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:
parent
ddb6762155
commit
df04ae29b2
|
@ -1,3 +1,18 @@
|
||||||
|
2003-07-26 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2003-07-25 Christopher Faylor <cgf@redhat.com>
|
2003-07-25 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* configure.in: Use 'install-sh -c'.
|
* configure.in: Use 'install-sh -c'.
|
||||||
|
|
|
@ -923,12 +923,12 @@ setup_handler (int sig, void *handler, struct sigaction& siga)
|
||||||
static BOOL WINAPI
|
static BOOL WINAPI
|
||||||
ctrl_c_handler (DWORD type)
|
ctrl_c_handler (DWORD type)
|
||||||
{
|
{
|
||||||
if (type == CTRL_LOGOFF_EVENT)
|
static bool saw_close;
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
/* Return FALSE to prevent an "End task" dialog box from appearing
|
/* Return FALSE to prevent an "End task" dialog box from appearing
|
||||||
for each Cygwin process window that's open when the computer
|
for each Cygwin process window that's open when the computer
|
||||||
is shut down or console window is closed. */
|
is shut down or console window is closed. */
|
||||||
|
|
||||||
if (type == CTRL_SHUTDOWN_EVENT)
|
if (type == CTRL_SHUTDOWN_EVENT)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -940,8 +940,12 @@ ctrl_c_handler (DWORD type)
|
||||||
#endif
|
#endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (type == CTRL_CLOSE_EVENT)
|
|
||||||
|
if (myself->ctty != -1
|
||||||
|
&& (type == CTRL_CLOSE_EVENT || (!saw_close && type == CTRL_LOGOFF_EVENT)))
|
||||||
{
|
{
|
||||||
|
if (type == CTRL_CLOSE_EVENT)
|
||||||
|
saw_close = true;
|
||||||
sig_send (NULL, SIGHUP);
|
sig_send (NULL, SIGHUP);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -555,9 +555,7 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
|
||||||
set_output_handle (to_master_local);
|
set_output_handle (to_master_local);
|
||||||
|
|
||||||
set_open_status ();
|
set_open_status ();
|
||||||
if (!output_done_event)
|
if (fhandler_console::open_fhs++ == 0 && !output_done_event
|
||||||
{
|
|
||||||
if (fhandler_console::open_fhs++ == 0
|
|
||||||
&& wincap.pty_needs_alloc_console ())
|
&& wincap.pty_needs_alloc_console ())
|
||||||
{
|
{
|
||||||
BOOL b;
|
BOOL b;
|
||||||
|
@ -573,7 +571,6 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
|
||||||
termios_printf ("%d = AllocConsole ()", b);
|
termios_printf ("%d = AllocConsole ()", b);
|
||||||
}
|
}
|
||||||
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
|
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
|
||||||
}
|
|
||||||
termios_printf ("tty%d opened", ttynum);
|
termios_printf ("tty%d opened", ttynum);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -582,12 +579,9 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
|
||||||
int
|
int
|
||||||
fhandler_tty_slave::close ()
|
fhandler_tty_slave::close ()
|
||||||
{
|
{
|
||||||
if (!output_done_event)
|
|
||||||
{
|
|
||||||
if (!--fhandler_console::open_fhs && myself->ctty == -1)
|
if (!--fhandler_console::open_fhs && myself->ctty == -1)
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
termios_printf ("decremented open_fhs %d", fhandler_console::open_fhs);
|
termios_printf ("decremented open_fhs %d", fhandler_console::open_fhs);
|
||||||
}
|
|
||||||
return fhandler_tty_common::close ();
|
return fhandler_tty_common::close ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,11 +849,8 @@ fhandler_tty_slave::read (void *ptr, size_t& len)
|
||||||
int
|
int
|
||||||
fhandler_tty_slave::dup (fhandler_base *child)
|
fhandler_tty_slave::dup (fhandler_base *child)
|
||||||
{
|
{
|
||||||
if (!output_done_event)
|
|
||||||
{
|
|
||||||
fhandler_console::open_fhs++;
|
fhandler_console::open_fhs++;
|
||||||
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
|
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
|
||||||
}
|
|
||||||
return fhandler_tty_common::dup (child);
|
return fhandler_tty_common::dup (child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1253,11 +1244,8 @@ fhandler_tty_common::set_close_on_exec (int val)
|
||||||
void
|
void
|
||||||
fhandler_tty_slave::fixup_after_fork (HANDLE parent)
|
fhandler_tty_slave::fixup_after_fork (HANDLE parent)
|
||||||
{
|
{
|
||||||
if (!output_done_event)
|
|
||||||
{
|
|
||||||
fhandler_console::open_fhs++;
|
fhandler_console::open_fhs++;
|
||||||
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
|
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
|
||||||
}
|
|
||||||
fhandler_tty_common::fixup_after_fork (parent);
|
fhandler_tty_common::fixup_after_fork (parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1317,6 +1305,7 @@ fhandler_tty_master::init_console ()
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
console->init (INVALID_HANDLE_VALUE, GENERIC_READ | GENERIC_WRITE, O_BINARY);
|
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);
|
console->set_r_no_interrupt (1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,14 +284,14 @@ setsid (void)
|
||||||
{
|
{
|
||||||
if (myself->ctty >= 0 && fhandler_console::open_fhs <= 0)
|
if (myself->ctty >= 0 && fhandler_console::open_fhs <= 0)
|
||||||
{
|
{
|
||||||
syscall_printf ("open_fhs %d, freeing console",
|
syscall_printf ("freeing console");
|
||||||
fhandler_console::open_fhs);
|
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
}
|
}
|
||||||
myself->ctty = -1;
|
myself->ctty = -1;
|
||||||
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, open_fhs %d", myself->sid,
|
||||||
|
myself->pgid, myself->ctty, fhandler_console::open_fhs);
|
||||||
return myself->sid;
|
return myself->sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue