forked from qt-creator/qt-creator
ios: cleaner kill of subprocess of iostoolhandler
try to first terminate (sig TERM) the tool before killing it (this ensures a cleaner shutdown of the connection to the device). Task-number: QTCREATORBUG-10922 Change-Id: Ib39fbd1d35a651cdb51364532bdef5b69cb1347e Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include <QScopedArrayPointer>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QFileInfo>
|
||||
#include <QTimer>
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
@@ -149,12 +150,14 @@ public:
|
||||
void subprocessError(QProcess::ProcessError error);
|
||||
void subprocessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void subprocessHasData();
|
||||
void killProcess();
|
||||
virtual bool expectsFileDescriptor() = 0;
|
||||
protected:
|
||||
void processXml();
|
||||
|
||||
IosToolHandler *q;
|
||||
QProcess process;
|
||||
QTimer killTimer;
|
||||
QXmlStreamReader outputParser;
|
||||
QString deviceId;
|
||||
QString bundlePath;
|
||||
@@ -200,6 +203,7 @@ IosToolHandlerPrivate::IosToolHandlerPrivate(IosToolHandler::DeviceType devType,
|
||||
q(q), state(NonStarted), devType(devType), iBegin(0), iEnd(0),
|
||||
gdbSocket(-1)
|
||||
{
|
||||
killTimer.setSingleShot(true);
|
||||
QProcessEnvironment env(QProcessEnvironment::systemEnvironment());
|
||||
foreach (const QString &k, env.keys())
|
||||
if (k.startsWith(QLatin1String("DYLD_")))
|
||||
@@ -219,6 +223,8 @@ IosToolHandlerPrivate::IosToolHandlerPrivate(IosToolHandler::DeviceType devType,
|
||||
q, SLOT(subprocessFinished(int,QProcess::ExitStatus)));
|
||||
QObject::connect(&process, SIGNAL(error(QProcess::ProcessError)),
|
||||
q, SLOT(subprocessError(QProcess::ProcessError)));
|
||||
QObject::connect(&killTimer, SIGNAL(timeout()),
|
||||
q, SLOT(killProcess()));
|
||||
}
|
||||
|
||||
bool IosToolHandlerPrivate::isRunning()
|
||||
@@ -268,8 +274,10 @@ void IosToolHandlerPrivate::stop(int errorCode)
|
||||
case Stopped:
|
||||
return;
|
||||
}
|
||||
if (process.state() != QProcess::NotRunning)
|
||||
process.kill();
|
||||
if (process.state() != QProcess::NotRunning) {
|
||||
process.terminate();
|
||||
killTimer.start(1500);
|
||||
}
|
||||
}
|
||||
|
||||
// signals
|
||||
@@ -341,6 +349,7 @@ void IosToolHandlerPrivate::subprocessFinished(int exitCode, QProcess::ExitStatu
|
||||
stop((exitStatus == QProcess::NormalExit) ? exitCode : -1 );
|
||||
if (debugToolHandler)
|
||||
qDebug() << "IosToolHandler::finished(" << this << ")";
|
||||
killTimer.stop();
|
||||
emit q->finished(q);
|
||||
}
|
||||
|
||||
@@ -693,6 +702,12 @@ void IosSimulatorToolHandlerPrivate::addDeviceArguments(QStringList &args) const
|
||||
}
|
||||
}
|
||||
|
||||
void IosToolHandlerPrivate::killProcess()
|
||||
{
|
||||
if (process.state() != QProcess::NotRunning)
|
||||
process.kill();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
QString IosToolHandler::iosDeviceToolPath()
|
||||
@@ -763,4 +778,9 @@ void IosToolHandler::subprocessHasData()
|
||||
d->subprocessHasData();
|
||||
}
|
||||
|
||||
void IosToolHandler::killProcess()
|
||||
{
|
||||
d->killProcess();
|
||||
}
|
||||
|
||||
} // namespace Ios
|
||||
|
@@ -99,6 +99,7 @@ private slots:
|
||||
void subprocessError(QProcess::ProcessError error);
|
||||
void subprocessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void subprocessHasData();
|
||||
void killProcess();
|
||||
private:
|
||||
friend class Ios::Internal::IosToolHandlerPrivate;
|
||||
Ios::Internal::IosToolHandlerPrivate *d;
|
||||
|
Reference in New Issue
Block a user