From 54aefd360c7941e302cb54d9c55317acfeb070b7 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 11 May 2009 11:51:52 +0000 Subject: [PATCH] Read standard output and error upon completion. And properly close the channels before killing the process. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29628 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/Systemcall.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp index 24548b6647..3d01683c96 100644 --- a/src/support/Systemcall.cpp +++ b/src/support/Systemcall.cpp @@ -19,6 +19,7 @@ #include "support/os.h" #include +#include #include @@ -29,6 +30,15 @@ using namespace std; namespace lyx { namespace support { +static void killProcess(QProcess * p) +{ + p->closeReadChannel(QProcess::StandardOutput); + p->closeReadChannel(QProcess::StandardError); + p->close(); + delete p; +} + + // Reuse of instance int Systemcall::startscript(Starttype how, string const & what) { @@ -50,6 +60,8 @@ int Systemcall::startscript(Starttype how, string const & what) #else QString cmd = QString::fromLocal8Bit(what.c_str()); QProcess * process = new QProcess; + cmd.replace("python", "python2.5"); + cmd.prepend("/usr/bin/"); process->start(cmd); if (!process->waitForStarted(1000)) { LYXERR0("Qprocess " << cmd << " did not start!"); @@ -76,7 +88,9 @@ int Systemcall::startscript(Starttype how, string const & what) LYXERR0("state " << process->state()); LYXERR0("status " << process->exitStatus()); } - delete process; + cout << fromqstr(QString::fromLocal8Bit(process->readAllStandardOutput().data())) << endl; + cerr << fromqstr(QString::fromLocal8Bit(process->readAllStandardError().data())) << endl; + killProcess(process); return exit_code; #endif } -- 2.39.2