Commit 21177273 authored by Ahmad Samir's avatar Ahmad Samir Committed by Tomaz Canabrava
Browse files

Port to Qt6 QProcess::setChildProcessModifier()

parent 46768ea1
......@@ -38,6 +38,28 @@ Pty::Pty(QObject *aParent)
void Pty::init()
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
// Must call parent class child process modifier, as it sets file descriptors ...etc
auto parentChildProcModifier = KPtyProcess::childProcessModifier();
setChildProcessModifier([parentChildProcModifier = std::move(parentChildProcModifier)]() {
if (parentChildProcModifier) {
parentChildProcModifier();
}
// reset all signal handlers
// this ensures that terminal applications respond to
// signals generated via key sequences such as Ctrl+C
// (which sends SIGINT)
struct sigaction action;
sigemptyset(&action.sa_mask);
action.sa_handler = SIG_DFL;
action.sa_flags = 0;
for (int signal = 1; signal < NSIG; signal++) {
sigaction(signal, &action, nullptr);
}
});
#endif
_windowColumns = 0;
_windowLines = 0;
_windowWidth = 0;
......@@ -310,6 +332,7 @@ int Pty::foregroundProcessGroup() const
return 0;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void Pty::setupChildProcess()
{
KPtyProcess::setupChildProcess();
......@@ -326,3 +349,4 @@ void Pty::setupChildProcess()
sigaction(signal, &action, nullptr);
}
}
#endif
......@@ -150,7 +150,10 @@ Q_SIGNALS:
void receivedData(const char *buffer, int length);
protected:
// TODO: remove this; in Qt6 use setChildProcessModifier() in init()
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void setupChildProcess() override;
#endif
private Q_SLOTS:
// called when data is received from the terminal process
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment