+ processEvents();
+}
+
+
+void SystemcallPrivate::processStarted()
+{
+ state = Running;
+ // why do we get two started signals?
+ //disconnect(proc_, SIGNAL(started()), this, SLOT(processStarted()));
+}
+
+
+void SystemcallPrivate::processFinished(int, QProcess::ExitStatus)
+{
+ state = Finished;
+}
+
+
+void SystemcallPrivate::processError(QProcess::ProcessError)
+{
+ state = Error;
+}
+
+
+QString SystemcallPrivate::errorMessage() const
+{
+ if (!proc_)
+ return "No QProcess available";
+
+ QString message;
+ switch (proc_->error()) {
+ case QProcess::FailedToStart:
+ message = "The process failed to start. Either the invoked program is missing, "
+ "or you may have insufficient permissions to invoke the program.";
+ break;
+ case QProcess::Crashed:
+ message = "The process crashed some time after starting successfully.";
+ break;
+ case QProcess::Timedout:
+ message = "The process timed out. It might be restarted automatically.";
+ break;
+ case QProcess::WriteError:
+ message = "An error occurred when attempting to write to the process-> For example, "
+ "the process may not be running, or it may have closed its input channel.";
+ break;
+ case QProcess::ReadError:
+ message = "An error occurred when attempting to read from the process-> For example, "
+ "the process may not be running.";
+ break;
+ case QProcess::UnknownError:
+ default:
+ message = "An unknown error occured.";
+ break;
+ }
+ return message;
+}
+
+
+QString SystemcallPrivate::exitStatusMessage() const
+{
+ if (!proc_)
+ return "No QProcess available";
+
+ QString message;
+ switch (proc_->exitStatus()) {
+ case QProcess::NormalExit:
+ message = "The process exited normally.";
+ break;
+ case QProcess::CrashExit:
+ message = "The process crashed.";
+ break;
+ default:
+ message = "Unknown exit state.";
+ break;
+ }
+ return message;
+}
+
+
+int SystemcallPrivate::exitCode()
+{
+ if (!proc_)
+ return -1;
+
+ return proc_->exitCode();
+}
+
+
+QProcess* SystemcallPrivate::releaseProcess()
+{
+ QProcess* released = proc_;
+ proc_ = 0;
+ return released;
+}
+
+
+void SystemcallPrivate::killProcess()
+{
+ killProcess(proc_);
+}
+
+
+void SystemcallPrivate::killProcess(QProcess * p)
+{
+ if (p) {
+ p->disconnect();
+ p->closeReadChannel(QProcess::StandardOutput);
+ p->closeReadChannel(QProcess::StandardError);
+ p->close();
+ delete p;
+ }