From 86fae567fa38097d0075dc8c145c48b11a9182fc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Feb 2020 15:33:15 -0800 Subject: [PATCH] TerminalControllingProcess: don't use qWarning in the child process qWarning() and all of QMessageLogger will get to qFormatLogMessage(), which locks a mutex. Additionally, qWarning may call a number of different backends that, in turn, may have mutexes of their own. Locking mutexes in child processes between fork() and execve() is a big no-no: it may have been locked by another thread before fork(), so it's still locked in the child process and will never get unlocked. Result: deadlock. Plus, qWarning reacts to QT_FATAL_WARNINGS, which I guess was not intended for this class. So just use a plain perror(), which is guaranteed by POSIX to be "MT-Safe race:stderr". Change-Id: I4e559af2a9a1455ab770fffd15f4a37a3fd113ca Reviewed-by: Alessandro Portale Reviewed-by: hjk Reviewed-by: Orgad Shaneh --- src/libs/utils/qtcprocess.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/qtcprocess.cpp b/src/libs/utils/qtcprocess.cpp index 3b92f649975..2088ae408fc 100644 --- a/src/libs/utils/qtcprocess.cpp +++ b/src/libs/utils/qtcprocess.cpp @@ -39,6 +39,7 @@ #include #else #include +#include #include #endif @@ -1226,7 +1227,7 @@ void QtcProcess::setupChildProcess() if (m_lowPriority) { errno = 0; if (::nice(5) == -1 && errno != 0) - qWarning("Failed to set nice value. Error: %d", errno); + perror("Failed to set nice value"); } #endif QProcess::setupChildProcess();