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 <alessandro.portale@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Thiago Macieira
2020-02-18 15:33:15 -08:00
committed by Orgad Shaneh
parent 6f1ad0b0cb
commit 86fae567fa

View File

@@ -39,6 +39,7 @@
#include <qt_windows.h> #include <qt_windows.h>
#else #else
#include <errno.h> #include <errno.h>
#include <stdio.h>
#include <unistd.h> #include <unistd.h>
#endif #endif
@@ -1226,7 +1227,7 @@ void QtcProcess::setupChildProcess()
if (m_lowPriority) { if (m_lowPriority) {
errno = 0; errno = 0;
if (::nice(5) == -1 && errno != 0) if (::nice(5) == -1 && errno != 0)
qWarning("Failed to set nice value. Error: %d", errno); perror("Failed to set nice value");
} }
#endif #endif
QProcess::setupChildProcess(); QProcess::setupChildProcess();