Lower priority on build

This should prevent slowdown of the IDE (and the rest of the system) while
building with all the CPU cores.

Fixes: QTCREATORBUG-5155
Change-Id: Icaadc53958f2d8e918035463e3c9344c91235615
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2019-09-10 23:39:29 +03:00
committed by Orgad Shaneh
parent 057215eb10
commit e38361b5a8
8 changed files with 54 additions and 5 deletions

View File

@@ -37,6 +37,9 @@
#ifdef Q_OS_WIN
#include <qt_windows.h>
#else
#include <errno.h>
#include <unistd.h>
#endif
@@ -712,9 +715,17 @@ void QtcProcess::start()
if (osType == OsTypeWindows) {
QString args;
if (m_useCtrlCStub) {
args = QtcProcess::quoteArg(QDir::toNativeSeparators(command));
if (m_lowPriority)
addArg(&args, "-nice");
addArg(&args, QDir::toNativeSeparators(command));
command = QCoreApplication::applicationDirPath()
+ QLatin1String("/qtcreator_ctrlc_stub.exe");
} else if (m_lowPriority) {
#ifdef Q_OS_WIN
setCreateProcessArgumentsModifier([](CreateProcessArguments *args) {
args->flags |= BELOW_NORMAL_PRIORITY_CLASS;
});
#endif
}
QtcProcess::addArgs(&args, arguments.toWindowsArgs());
#ifdef Q_OS_WIN
@@ -1208,6 +1219,19 @@ QString QtcProcess::expandMacros(const QString &str, AbstractMacroExpander *mx,
return ret;
}
void QtcProcess::setupChildProcess()
{
#if defined Q_OS_UNIX
// nice value range is -20 to +19 where -20 is highest, 0 default and +19 is lowest
if (m_lowPriority) {
errno = 0;
if (::nice(5) == -1 && errno != 0)
qWarning("Failed to set nice value. Error: %d", errno);
}
#endif
QProcess::setupChildProcess();
}
bool QtcProcess::ArgIterator::next()
{
// We delay the setting of m_prev so we can still delete the last argument