From 0ef9762bbb176c842a90bc5aaad49a7f2b054ad6 Mon Sep 17 00:00:00 2001 From: Murray Read Date: Wed, 7 Mar 2012 11:47:41 +0000 Subject: Don't allow app panic on QProcess destruction, kill or terminate QProcess destruction will call kill() if the process is still running. PRocess::Kill() and Terminate() both require the PowerMgmt capability to operate on Symbian, otherwise a KERN-EXEC 46 panic happens. An app should be able to use QProcess safely if it doesn't have PowerMgmt capability, it should just be prevented from trying to kill the created process. Now a debug message is issued on ~QProcess(), kill() or terminate() if the capability is not present, rather than actually trying to kill/terminate the process. Task-number: ou1cimx1#985227 Change-Id: I3242ca2c39528c70c2c79e39f6a6384dd72f6ae6 Reviewed-by: Shane Kearns --- src/corelib/io/qprocess_symbian.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qprocess_symbian.cpp b/src/corelib/io/qprocess_symbian.cpp index 2ed7fe6..c483b76 100644 --- a/src/corelib/io/qprocess_symbian.cpp +++ b/src/corelib/io/qprocess_symbian.cpp @@ -890,10 +890,14 @@ qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen) void QProcessPrivate::terminateProcess() { - // Needs PowerMgmt capability if process has been started; will panic kern-exec 46 otherwise. + // Needs PowerMgmt capability if process has been started; will issue a debug message otherwise. // Always works if process is not yet started. if (qt_rprocess_running(symbianProcess)) { - symbianProcess->Terminate(0); + if (RProcess().HasCapability(ECapabilityPowerMgmt)) { + symbianProcess->Terminate(0); + } else { + qWarning("QProcessPrivate::terminateProcess(), can't terminate process without PowerMgmt capability"); + } } else { QPROCESS_DEBUG_PRINT("QProcessPrivate::terminateProcess(), Process not running"); } @@ -901,10 +905,14 @@ void QProcessPrivate::terminateProcess() void QProcessPrivate::killProcess() { - // Needs PowerMgmt capability if process has been started; will panic kern-exec 46 otherwise. + // Needs PowerMgmt capability if process has been started; will issue a debug message otherwise. // Always works if process is not yet started. if (qt_rprocess_running(symbianProcess)) { - symbianProcess->Kill(0); + if (RProcess().HasCapability(ECapabilityPowerMgmt)) { + symbianProcess->Kill(0); + } else { + qWarning("QProcessPrivate::killProcess(), can't kill process without PowerMgmt capability"); + } } else { QPROCESS_DEBUG_PRINT("QProcessPrivate::killProcess(), Process not running"); } -- cgit v0.12