Cygwin: pty: Isolate CTRL_C_EVENTs between ptys.
- With this patch, unique invisible consoles are created for each pty to isolate CTRL_C_EVENTs between ptys. This is necessary by Ctrl-C handling in fhandler_termios::process_sigs() for non-cygwin apps started in pty if the pseudo console is disabled.
This commit is contained in:
parent
8ff9f216fd
commit
95a28b1f9e
|
@ -368,8 +368,7 @@ fhandler_termios::process_sigs (char c, tty* ttyp, fhandler_termios *fh)
|
||||||
{
|
{
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
AttachConsole (p->dwProcessId);
|
AttachConsole (p->dwProcessId);
|
||||||
if (::cygheap->ctty && ::cygheap->ctty->is_console ())
|
init_console_handler (true);
|
||||||
init_console_handler (true);
|
|
||||||
}
|
}
|
||||||
if (fh && p == myself && being_debugged ())
|
if (fh && p == myself && being_debugged ())
|
||||||
{ /* Avoid deadlock in gdb on console. */
|
{ /* Avoid deadlock in gdb on console. */
|
||||||
|
@ -393,8 +392,7 @@ fhandler_termios::process_sigs (char c, tty* ttyp, fhandler_termios *fh)
|
||||||
{
|
{
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
AttachConsole (resume_pid);
|
AttachConsole (resume_pid);
|
||||||
if (::cygheap->ctty && ::cygheap->ctty->is_console ())
|
init_console_handler (true);
|
||||||
init_console_handler (true);
|
|
||||||
}
|
}
|
||||||
need_discard_input = true;
|
need_discard_input = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -547,6 +547,7 @@ fhandler_pty_master::accept_input ()
|
||||||
cp_to = GetConsoleCP ();
|
cp_to = GetConsoleCP ();
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
AttachConsole (resume_pid);
|
AttachConsole (resume_pid);
|
||||||
|
init_console_handler (true);
|
||||||
release_attach_mutex ();
|
release_attach_mutex ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -967,6 +968,12 @@ fhandler_pty_slave::open (int flags, mode_t)
|
||||||
this behaviour, protection based on attach_mutex does
|
this behaviour, protection based on attach_mutex does
|
||||||
not take effect. */
|
not take effect. */
|
||||||
get_ttyp ()->need_invisible_console = true;
|
get_ttyp ()->need_invisible_console = true;
|
||||||
|
else if (_major (myself->ctty) != DEV_CONS_MAJOR
|
||||||
|
&& (!get_ttyp ()->invisible_console_pid
|
||||||
|
|| !pinfo (get_ttyp ()->invisible_console_pid)))
|
||||||
|
/* Create a new invisible console for each pty to isolate
|
||||||
|
CTRL_C_EVENTs between ptys. */
|
||||||
|
get_ttyp ()->need_invisible_console = true;
|
||||||
else
|
else
|
||||||
fhandler_console::need_invisible ();
|
fhandler_console::need_invisible ();
|
||||||
|
|
||||||
|
@ -1027,6 +1034,7 @@ fhandler_pty_slave::close ()
|
||||||
fhandler_pty_common::close ();
|
fhandler_pty_common::close ();
|
||||||
if (!ForceCloseHandle (output_mutex))
|
if (!ForceCloseHandle (output_mutex))
|
||||||
termios_printf ("CloseHandle (output_mutex<%p>), %E", output_mutex);
|
termios_printf ("CloseHandle (output_mutex<%p>), %E", output_mutex);
|
||||||
|
get_ttyp ()->invisible_console_pid = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1232,12 +1240,14 @@ fhandler_pty_slave::reset_switch_to_pcon (void)
|
||||||
0, TRUE, DUPLICATE_SAME_ACCESS);
|
0, TRUE, DUPLICATE_SAME_ACCESS);
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
AttachConsole (get_ttyp ()->pcon_pid);
|
AttachConsole (get_ttyp ()->pcon_pid);
|
||||||
|
init_console_handler (true);
|
||||||
WaitForSingleObject (input_mutex, mutex_timeout);
|
WaitForSingleObject (input_mutex, mutex_timeout);
|
||||||
transfer_input (tty::to_cyg, h_pcon_in, get_ttyp (),
|
transfer_input (tty::to_cyg, h_pcon_in, get_ttyp (),
|
||||||
input_available_event);
|
input_available_event);
|
||||||
ReleaseMutex (input_mutex);
|
ReleaseMutex (input_mutex);
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
AttachConsole (resume_pid);
|
AttachConsole (resume_pid);
|
||||||
|
init_console_handler (true);
|
||||||
CloseHandle (h_pcon_in);
|
CloseHandle (h_pcon_in);
|
||||||
}
|
}
|
||||||
CloseHandle (pcon_owner);
|
CloseHandle (pcon_owner);
|
||||||
|
@ -2839,6 +2849,7 @@ fhandler_pty_master::pty_master_fwd_thread (const master_fwd_thread_param_t *p)
|
||||||
cp_from = GetConsoleOutputCP ();
|
cp_from = GetConsoleOutputCP ();
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
AttachConsole (resume_pid);
|
AttachConsole (resume_pid);
|
||||||
|
init_console_handler (true);
|
||||||
release_attach_mutex ();
|
release_attach_mutex ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3261,6 +3272,7 @@ fhandler_pty_slave::setup_pseudoconsole (bool nopcon)
|
||||||
CloseHandle (pcon_owner);
|
CloseHandle (pcon_owner);
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
AttachConsole (get_ttyp ()->pcon_pid);
|
AttachConsole (get_ttyp ()->pcon_pid);
|
||||||
|
init_console_handler (true);
|
||||||
goto skip_create;
|
goto skip_create;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3384,6 +3396,7 @@ fhandler_pty_slave::setup_pseudoconsole (bool nopcon)
|
||||||
/* Attach to pseudo console */
|
/* Attach to pseudo console */
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
AttachConsole (pi.dwProcessId);
|
AttachConsole (pi.dwProcessId);
|
||||||
|
init_console_handler (true);
|
||||||
|
|
||||||
/* Terminate helper process */
|
/* Terminate helper process */
|
||||||
SetEvent (goodbye);
|
SetEvent (goodbye);
|
||||||
|
@ -3573,6 +3586,7 @@ fhandler_pty_slave::close_pseudoconsole (tty *ttyp, DWORD force_switch_to)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
AttachConsole (ATTACH_PARENT_PROCESS);
|
AttachConsole (ATTACH_PARENT_PROCESS);
|
||||||
|
init_console_handler (true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* Close pseudo console */
|
{ /* Close pseudo console */
|
||||||
|
@ -3585,6 +3599,7 @@ fhandler_pty_slave::close_pseudoconsole (tty *ttyp, DWORD force_switch_to)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
AttachConsole (ATTACH_PARENT_PROCESS);
|
AttachConsole (ATTACH_PARENT_PROCESS);
|
||||||
|
init_console_handler (true);
|
||||||
/* Reconstruct pseudo console handler container here for close */
|
/* Reconstruct pseudo console handler container here for close */
|
||||||
HPCON_INTERNAL *hp =
|
HPCON_INTERNAL *hp =
|
||||||
(HPCON_INTERNAL *) HeapAlloc (GetProcessHeap (), 0,
|
(HPCON_INTERNAL *) HeapAlloc (GetProcessHeap (), 0,
|
||||||
|
@ -3613,6 +3628,7 @@ fhandler_pty_slave::close_pseudoconsole (tty *ttyp, DWORD force_switch_to)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
AttachConsole (ATTACH_PARENT_PROCESS);
|
AttachConsole (ATTACH_PARENT_PROCESS);
|
||||||
|
init_console_handler (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (pcon_pid_self (ttyp->pcon_pid))
|
else if (pcon_pid_self (ttyp->pcon_pid))
|
||||||
|
@ -3779,6 +3795,7 @@ fhandler_pty_slave::create_invisible_console ()
|
||||||
/* Detach from console device and create new invisible console. */
|
/* Detach from console device and create new invisible console. */
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
fhandler_console::need_invisible (true);
|
fhandler_console::need_invisible (true);
|
||||||
|
init_console_handler (true);
|
||||||
get_ttyp ()->need_invisible_console = false;
|
get_ttyp ()->need_invisible_console = false;
|
||||||
get_ttyp ()->invisible_console_pid = myself->pid;
|
get_ttyp ()->invisible_console_pid = myself->pid;
|
||||||
}
|
}
|
||||||
|
@ -4085,6 +4102,7 @@ fhandler_pty_slave::setpgid_aux (pid_t pid)
|
||||||
CloseHandle (pcon_owner);
|
CloseHandle (pcon_owner);
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
AttachConsole (get_ttyp ()->pcon_pid);
|
AttachConsole (get_ttyp ()->pcon_pid);
|
||||||
|
init_console_handler (true);
|
||||||
attach_restore = true;
|
attach_restore = true;
|
||||||
}
|
}
|
||||||
WaitForSingleObject (input_mutex, mutex_timeout);
|
WaitForSingleObject (input_mutex, mutex_timeout);
|
||||||
|
@ -4101,6 +4119,7 @@ fhandler_pty_slave::setpgid_aux (pid_t pid)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
AttachConsole (ATTACH_PARENT_PROCESS);
|
AttachConsole (ATTACH_PARENT_PROCESS);
|
||||||
|
init_console_handler (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReleaseMutex (pcon_mutex);
|
ReleaseMutex (pcon_mutex);
|
||||||
|
|
Loading…
Reference in New Issue