forked from qt-creator/qt-creator
Docker: Use shell to exit container
..and only fallback to calling docker command if this fails. Change-Id: I854499f7df8605ffe444c43bc6d1dc0155183627 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -304,7 +304,7 @@ public:
|
||||
});
|
||||
}
|
||||
|
||||
~DockerDevicePrivate() { delete m_shell; }
|
||||
~DockerDevicePrivate() { stopCurrentContainer(); }
|
||||
|
||||
bool runInContainer(const CommandLine &cmd) const;
|
||||
|
||||
@@ -745,6 +745,19 @@ void DockerDevicePrivate::stopCurrentContainer()
|
||||
if (m_container.isEmpty() || m_accessible == NoDaemon)
|
||||
return;
|
||||
|
||||
if (m_shell) {
|
||||
m_shell->write("exit\n");
|
||||
m_shell->waitForFinished(2000);
|
||||
if (m_shell->state() == QProcess::NotRunning) {
|
||||
LOG("Clean exit via shell");
|
||||
m_container.clear();
|
||||
m_mergedDir.clear();
|
||||
delete m_shell;
|
||||
m_shell = nullptr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QtcProcess proc;
|
||||
proc.setCommand({"docker", {"container", "stop", m_container}});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user