- After commit
e1a0775dc0545b5f9c81b09a327fc110c538b7b4, 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 commit
e1a0775dc0545b5f9c81b09a327fc110c538b7b4 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.
return get_ttyp ()->ti.c_lflag & ICANON;
}
void setup_locale (void);
+ void set_freeconsole_on_close (bool val);
};
#define __ptsname(buf, unit) __small_sprintf ((buf), "/dev/pty%d", (unit))
static int pcon_attached_to = -1;
static bool isHybrid;
static bool do_not_reset_switch_to_pcon;
+static bool freeconsole_on_close = true;
#if USE_API_HOOK
static void
if (used == 0)
{
init_console_handler (false);
- FreeConsole ();
+ if (freeconsole_on_close)
+ FreeConsole ();
}
}
}
}
}
+void
+fhandler_pty_slave::set_freeconsole_on_close (bool val)
+{
+ freeconsole_on_close = val;
+}
+
void
fhandler_pty_slave::fixup_after_attach (bool native_maybe, int fd_set)
{
if (used == 1 /* About to close this tty */)
{
init_console_handler (false);
- FreeConsole ();
+ if (freeconsole_on_close)
+ FreeConsole ();
}
}
attach_to_console = true;
}
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)
NtClose (old_winpid_hdl);
real_path.get_wide_win32_path (myself->progname); // FIXME: race?
sigproc_printf ("new process name %W", myself->progname);
+ if (!iscygwin ())
+ close_all_files ();
}
else
{
wait_for_myself ();
}
myself.exit (EXITCODE_NOSET);
- if (!iscygwin ())
- close_all_files ();
break;
case _P_WAIT:
case _P_SYSTEM: