return fh;
}
bool setup_pseudoconsole (STARTUPINFOEXW *si, bool nopcon);
- void close_pseudoconsole (void);
+ static void close_pseudoconsole (tty *ttyp);
bool term_has_pcon_cap (const WCHAR *env);
void set_switch_to_pcon (void);
void reset_switch_to_pcon (void);
void mask_switch_to_pcon_in (bool mask);
void setup_locale (void);
+ tty *get_ttyp () { return (tty *) tc (); } /* Override as public */
};
#define __ptsname(buf, unit) __small_sprintf ((buf), "/dev/pty%d", (unit))
return false;
}
+/* The function close_pseudoconsole() should be static so that it can
+ be called even after the fhandler_pty_slave instance is deleted. */
void
-fhandler_pty_slave::close_pseudoconsole (void)
+fhandler_pty_slave::close_pseudoconsole (tty *ttyp)
{
- if (get_ttyp ()->h_pseudo_console)
+ if (ttyp->h_pseudo_console)
{
- get_ttyp ()->wait_pcon_fwd ();
- HPCON_INTERNAL *hp = (HPCON_INTERNAL *) get_ttyp ()->h_pseudo_console;
+ ttyp->wait_pcon_fwd ();
+ HPCON_INTERNAL *hp = (HPCON_INTERNAL *) ttyp->h_pseudo_console;
HANDLE tmp = hp->hConHostProcess;
- ClosePseudoConsole (get_ttyp ()->h_pseudo_console);
+ ClosePseudoConsole (ttyp->h_pseudo_console);
CloseHandle (tmp);
- get_ttyp ()->h_pseudo_console = NULL;
- get_ttyp ()->switch_to_pcon_in = false;
- get_ttyp ()->pcon_pid = 0;
- get_ttyp ()->pcon_start = false;
- get_ttyp ()->do_not_resize_pcon = false;
+ ttyp->h_pseudo_console = NULL;
+ ttyp->switch_to_pcon_in = false;
+ ttyp->pcon_pid = 0;
+ ttyp->pcon_start = false;
+ ttyp->do_not_resize_pcon = false;
}
}
init_console_handler (myself->ctty > 0);
bool enable_pcon = false;
+ tty *ptys_ttyp = NULL;
STARTUPINFOEXW si_pcon;
ZeroMemory (&si_pcon, sizeof (si_pcon));
STARTUPINFOW *si_tmp = &si;
c_flags |= EXTENDED_STARTUPINFO_PRESENT;
si_tmp = &si_pcon.StartupInfo;
enable_pcon = true;
+ ptys_ttyp = ptys_primary->get_ttyp ();
}
}
if (enable_pcon)
{
WaitForSingleObject (pi.hProcess, INFINITE);
- ptys_primary->close_pseudoconsole ();
+ fhandler_pty_slave::close_pseudoconsole (ptys_ttyp);
}
else if (cons_native)
{
if (waitpid (cygpid, &res, 0) != cygpid)
res = -1;
if (enable_pcon)
- ptys_primary->close_pseudoconsole ();
+ fhandler_pty_slave::close_pseudoconsole (ptys_ttyp);
else if (cons_native)
{
fhandler_console::request_xterm_mode_output (true,