aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFawzi Mohamed <fawzi.mohamed@digia.com>2013-12-04 12:58:29 +0100
committerFawzi Mohamed <fawzi.mohamed@digia.com>2013-12-04 15:40:07 +0100
commit5d4e9066c8c53f2612f809b5f6d28b0c39561ec1 (patch)
tree7f04dba536322458c41d21b74af4a00c9c68df7c
parentfccffba04bbac0439583272b1c73151e9a00b0c6 (diff)
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>
-rw-r--r--src/plugins/ios/iostoolhandler.cpp24
-rw-r--r--src/plugins/ios/iostoolhandler.h1
2 files changed, 23 insertions, 2 deletions
diff --git a/src/plugins/ios/iostoolhandler.cpp b/src/plugins/ios/iostoolhandler.cpp
index bda73d5bab..8431331952 100644
--- a/src/plugins/ios/iostoolhandler.cpp
+++ b/src/plugins/ios/iostoolhandler.cpp
@@ -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
diff --git a/src/plugins/ios/iostoolhandler.h b/src/plugins/ios/iostoolhandler.h
index 11c4a56e75..de8e53c484 100644
--- a/src/plugins/ios/iostoolhandler.h
+++ b/src/plugins/ios/iostoolhandler.h
@@ -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;