issue a warning in legacy W10 terminals (PS/cmd)

Those terminal emulators block stdout/stderr output when scrolled,
which effectively stops UltraGrid. The behavior doesn't occur in MS
Terminal app, which is encouraged instead.

Note that Windows Terminal still runs cmd.exe or powershell.exe as a shell
while the cmd/PS process can acts like both terminal emulator and
shell. We also do not trigger the warning if UG is run from within
MSYS2 terminal.
This commit is contained in:
Martin Pulec
2024-01-26 15:04:53 +01:00
parent 7393a244f8
commit bb2a72f67f
3 changed files with 61 additions and 8 deletions

View File

@@ -116,6 +116,8 @@ extern "C" {
#include <mcheck.h>
#endif
#define MOD_NAME "[host] "
using std::array;
using std::cout;
using std::endl;
@@ -458,6 +460,16 @@ struct init_data *common_preinit(int argc, char *argv[])
if (init_com) {
com_initialize(&init.com_initialized, nullptr);
}
// warn in W10 "legacy" terminal emulators
if ((win_has_ancestor_process("powershell.exe") ||
win_has_ancestor_process("cmd.exe")) &&
!win_has_ancestor_process("WindowsTerminal.exe")) {
MSG(WARNING, "Running inside PS/cmd terminal is not recommended "
"because scrolling the output freezes the process, "
"consider using Windows Terminal instead!\n");
Sleep(1000);
}
#endif
if (strstr(argv[0], "run_tests") == nullptr) {