mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-09 18:52:46 +00:00
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
This commit is contained in:
parent
3e3179b4d4
commit
54aefd360c
@ -19,6 +19,7 @@
|
||||
#include "support/os.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user