Windows port: ConPTY via ptyqt, POSIX guards

This commit is contained in:
2026-05-04 16:23:23 +02:00
parent a42fa8bf95
commit e6bda0c239
7 changed files with 238 additions and 134 deletions
+12 -3
View File
@@ -84,7 +84,11 @@ Session::Session(QObject* parent) :
//create teletype for I/O with shell process
_shellProcess = new Pty();
#if !defined(Q_OS_WIN)
ptySlaveFd = _shellProcess->pty()->slaveFd();
#else
ptySlaveFd = -1;
#endif
//create emulation backend
_emulation = new Vt102Emulation();
@@ -258,11 +262,15 @@ void Session::run()
* their computing time on any system - especially with the problem on arch linux beeing there too.
*/
QString exec = QString::fromLocal8Bit(QFile::encodeName(_program));
#if defined(Q_OS_WIN)
if (exec.isEmpty()) {
exec = QString::fromLocal8Bit(qgetenv("COMSPEC"));
if (exec.isEmpty())
exec = QStringLiteral("cmd.exe");
}
#else
// if 'exec' is not specified, fall back to default shell. if that
// is not set then fall back to /bin/sh
// here we expect full path. If there is no fullpath let's expect it's
// a custom shell (eg. python, etc.) available in the PATH.
if (exec.startsWith(QLatin1Char('/')) || exec.isEmpty())
{
const QString defaultShell{QLatin1String("/bin/sh")};
@@ -278,6 +286,7 @@ void Session::run()
exec = defaultShell;
}
}
#endif
// _arguments sometimes contain ("") so isEmpty()
// or count() does not work as expected...