forked from qt-creator/qt-creator
Docker: prevent endless loop after shell stopped
Change-Id: Id2ee7193ab7b646e85f2a84f673cb3022fec4dba Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1696,13 +1696,14 @@ QString DockerDevicePrivate::outputForRunInShell(const CommandLine &cmd) const
|
|||||||
{
|
{
|
||||||
if (!DockerPlugin::isDaemonRunning().value_or(false))
|
if (!DockerPlugin::isDaemonRunning().value_or(false))
|
||||||
return {};
|
return {};
|
||||||
QTC_ASSERT(m_shell, return {});
|
QTC_ASSERT(m_shell && m_shell->isRunning(), return {});
|
||||||
QMutexLocker l(&m_shellMutex);
|
QMutexLocker l(&m_shellMutex);
|
||||||
m_shell->readAllStandardOutput(); // clean possible left-overs
|
m_shell->readAllStandardOutput(); // clean possible left-overs
|
||||||
const QByteArray markerWithNewLine("___QC_DOCKER_" + randomHex() + "_OUTPUT_MARKER___\n");
|
const QByteArray markerWithNewLine("___QC_DOCKER_" + randomHex() + "_OUTPUT_MARKER___\n");
|
||||||
m_shell->write(cmd.toUserOutput().toUtf8() + "\necho -n \"" + markerWithNewLine + "\"\n");
|
m_shell->write(cmd.toUserOutput().toUtf8() + "\necho -n \"" + markerWithNewLine + "\"\n");
|
||||||
QByteArray output;
|
QByteArray output;
|
||||||
while (!output.endsWith(markerWithNewLine)) {
|
while (!output.endsWith(markerWithNewLine)) {
|
||||||
|
QTC_ASSERT(m_shell->isRunning(), return {});
|
||||||
m_shell->waitForReadyRead();
|
m_shell->waitForReadyRead();
|
||||||
output.append(m_shell->readAllStandardOutput());
|
output.append(m_shell->readAllStandardOutput());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user