Launching ipconfig using QProcess
causes a crash with an error dialog
Runtime error!
c:\Windows\SysWOW64\ipconfig.exe
R6016
- not enough space for thread data
on some machines (it is not everywhere that the problem occurs), see image.
Am I incorrectly using QProcess
?
I tested in:
- Windows 7 64ibt
- Windows 8/10
Using:
- QT5.8.0
- Mingw 5.3 32bit
Minimal code:
#include <QApplication>
#include <QWidget>
#include <QTimer>
#include <QProcess>
#include <QRegExp>
#include <QDebug>
QProcess *checkGateway;
void detectGateway() {
//Start ipconfig
QProcess* proc = new QProcess();
QObject::connect(proc, static_cast<void (QProcess::*)(int)>(&QProcess::finished), [proc](int exitStatus) {
Q_UNUSED(exitStatus);
/* parse */
int testAfter = 1000; //1 sec
QRegExp rx("gateway[^\\r\\n]+(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})");
rx.setCaseSensitivity(Qt::CaseInsensitive);
const QString getResp = proc->readAll();
if (rx.indexIn(getResp) > -1) {
qDebug() << "Gateway:" << rx.cap(1);
testAfter = 5000; //5 sec
} else {
qDebug() << "Not found";
}
QTimer::singleShot(testAfter, [](){
detectGateway();
});
/* parse */
});
proc->start("ipconfig");
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
detectGateway();
w.show();
return a.exec();
}