Cygwin: pty: Disable FreeConsole() on close for non cygwin process.
- After commite1a0775dc0
, the problem reported in https://www.cygwin.com/ml/cygwin/2020-01/msg00093.html occurs. For Gnu scren and tmux, calling FreeConsole() on pty close is necessary. However, if FreeConsole() is called, cygwin setup with '-h' option does not work. Therefore, the commite1a0775dc0
delayed closing pty. This is the cause of the problem above. Now, instead of delaying pty close, FreeConsole() is not called if the process is non cygwin processes such as cygwin setup.
This commit is contained in:
parent
9e28f50097
commit
145c1db7f8
|
@ -2206,6 +2206,7 @@ class fhandler_pty_slave: public fhandler_pty_common
|
||||||
return get_ttyp ()->ti.c_lflag & ICANON;
|
return get_ttyp ()->ti.c_lflag & ICANON;
|
||||||
}
|
}
|
||||||
void setup_locale (void);
|
void setup_locale (void);
|
||||||
|
void set_freeconsole_on_close (bool val);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define __ptsname(buf, unit) __small_sprintf ((buf), "/dev/pty%d", (unit))
|
#define __ptsname(buf, unit) __small_sprintf ((buf), "/dev/pty%d", (unit))
|
||||||
|
|
|
@ -66,6 +66,7 @@ struct pipe_reply {
|
||||||
static int pcon_attached_to = -1;
|
static int pcon_attached_to = -1;
|
||||||
static bool isHybrid;
|
static bool isHybrid;
|
||||||
static bool do_not_reset_switch_to_pcon;
|
static bool do_not_reset_switch_to_pcon;
|
||||||
|
static bool freeconsole_on_close = true;
|
||||||
|
|
||||||
#if USE_API_HOOK
|
#if USE_API_HOOK
|
||||||
static void
|
static void
|
||||||
|
@ -725,6 +726,7 @@ fhandler_pty_slave::~fhandler_pty_slave ()
|
||||||
if (used == 0)
|
if (used == 0)
|
||||||
{
|
{
|
||||||
init_console_handler (false);
|
init_console_handler (false);
|
||||||
|
if (freeconsole_on_close)
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2660,6 +2662,12 @@ fhandler_pty_slave::setup_locale (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fhandler_pty_slave::set_freeconsole_on_close (bool val)
|
||||||
|
{
|
||||||
|
freeconsole_on_close = val;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fhandler_pty_slave::fixup_after_attach (bool native_maybe, int fd_set)
|
fhandler_pty_slave::fixup_after_attach (bool native_maybe, int fd_set)
|
||||||
{
|
{
|
||||||
|
@ -2783,6 +2791,7 @@ fhandler_pty_slave::fixup_after_exec ()
|
||||||
if (used == 1 /* About to close this tty */)
|
if (used == 1 /* About to close this tty */)
|
||||||
{
|
{
|
||||||
init_console_handler (false);
|
init_console_handler (false);
|
||||||
|
if (freeconsole_on_close)
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -607,6 +607,8 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
|
||||||
attach_to_console = true;
|
attach_to_console = true;
|
||||||
}
|
}
|
||||||
ptys->fixup_after_attach (!iscygwin (), fd);
|
ptys->fixup_after_attach (!iscygwin (), fd);
|
||||||
|
if (mode == _P_OVERLAY)
|
||||||
|
ptys->set_freeconsole_on_close (iscygwin ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (fh && fh->get_major () == DEV_CONS_MAJOR)
|
else if (fh && fh->get_major () == DEV_CONS_MAJOR)
|
||||||
|
@ -809,6 +811,8 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
|
||||||
NtClose (old_winpid_hdl);
|
NtClose (old_winpid_hdl);
|
||||||
real_path.get_wide_win32_path (myself->progname); // FIXME: race?
|
real_path.get_wide_win32_path (myself->progname); // FIXME: race?
|
||||||
sigproc_printf ("new process name %W", myself->progname);
|
sigproc_printf ("new process name %W", myself->progname);
|
||||||
|
if (!iscygwin ())
|
||||||
|
close_all_files ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -907,8 +911,6 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
|
||||||
wait_for_myself ();
|
wait_for_myself ();
|
||||||
}
|
}
|
||||||
myself.exit (EXITCODE_NOSET);
|
myself.exit (EXITCODE_NOSET);
|
||||||
if (!iscygwin ())
|
|
||||||
close_all_files ();
|
|
||||||
break;
|
break;
|
||||||
case _P_WAIT:
|
case _P_WAIT:
|
||||||
case _P_SYSTEM:
|
case _P_SYSTEM:
|
||||||
|
|
Loading…
Reference in New Issue