forked from qt-creator/qt-creator
Reuse ProcessHelper in process launcher
Handle lowPriority and unixTerminalDisabled inside process launcher. Change-Id: I7a8998e303da0e79186c1201fc6e1a76edb4e1b3 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -24,13 +24,13 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "processutils.h"
|
||||
#include <QProcess>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#ifdef QTCREATOR_PCH_H
|
||||
#define CALLBACK WINAPI
|
||||
#endif
|
||||
#include <qt_windows.h>
|
||||
#else
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace Utils {
|
||||
@@ -86,4 +86,21 @@ void ProcessStartHandler::setNativeArguments(QProcess *process, const QString &a
|
||||
#endif // Q_OS_WIN
|
||||
}
|
||||
|
||||
|
||||
void ProcessHelper::setupChildProcess_impl()
|
||||
{
|
||||
#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)
|
||||
perror("Failed to set nice value");
|
||||
}
|
||||
|
||||
// Disable terminal by becoming a session leader.
|
||||
if (m_unixTerminalDisabled)
|
||||
setsid();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
||||
Reference in New Issue
Block a user