3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup
8 * Interface cleaned up by
9 * \author Angus Leeming
11 * Full author contact details are available in file CREDITS.
16 #include "support/debug.h"
17 #include "support/qstring_helpers.h"
18 #include "support/Systemcall.h"
19 #include "support/os.h"
26 #define DISABLE_EVALUATE_QPROCESS
33 static void killProcess(QProcess * p)
35 p->closeReadChannel(QProcess::StandardOutput);
36 p->closeReadChannel(QProcess::StandardError);
43 int Systemcall::startscript(Starttype how, string const & what)
45 #ifdef DISABLE_EVALUATE_QPROCESS
46 string command = what;
48 if (how == DontWait) {
49 switch (os::shell()) {
54 command = "start /min " + command;
59 return ::system(command.c_str());
61 QString cmd = QString::fromLocal8Bit(what.c_str());
62 QProcess * process = new QProcess;
63 cmd.replace("python", "python2.5");
64 cmd.prepend("/usr/bin/");
66 if (!process->waitForStarted(1000)) {
67 LYXERR0("Qprocess " << cmd << " did not start!");
68 LYXERR0("error " << process->error());
69 LYXERR0("state " << process->state());
70 LYXERR0("status " << process->exitStatus());
76 if (!process->waitForFinished(30000)) {
77 LYXERR0("Qprocess " << cmd << " did not finished!");
78 LYXERR0("error " << process->error());
79 LYXERR0("state " << process->state());
80 LYXERR0("status " << process->exitStatus());
83 int const exit_code = process->exitCode();
85 LYXERR0("Qprocess " << cmd << " finished!");
86 LYXERR0("exitCode " << process->exitCode());
87 LYXERR0("error " << process->error());
88 LYXERR0("state " << process->state());
89 LYXERR0("status " << process->exitStatus());
91 cout << fromqstr(QString::fromLocal8Bit(process->readAllStandardOutput().data())) << endl;
92 cerr << fromqstr(QString::fromLocal8Bit(process->readAllStandardError().data())) << endl;
98 } // namespace support