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"
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)
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;
64 if (!process->waitForStarted(3000)) {
65 LYXERR0("Qprocess " << cmd << " did not start!");
66 LYXERR0("error " << process->error());
67 LYXERR0("state " << process->state());
68 LYXERR0("status " << process->exitStatus());
74 if (!process->waitForFinished(180000)) {
75 LYXERR0("Qprocess " << cmd << " did not finished!");
76 LYXERR0("error " << process->error());
77 LYXERR0("state " << process->state());
78 LYXERR0("status " << process->exitStatus());
81 int const exit_code = process->exitCode();
83 LYXERR0("Qprocess " << cmd << " finished!");
84 LYXERR0("exitCode " << process->exitCode());
85 LYXERR0("error " << process->error());
86 LYXERR0("state " << process->state());
87 LYXERR0("status " << process->exitStatus());
89 cout << fromqstr(QString::fromLocal8Bit(process->readAllStandardOutput().data())) << endl;
90 cerr << fromqstr(QString::fromLocal8Bit(process->readAllStandardError().data())) << endl;
96 } // namespace support