]> git.lyx.org Git - lyx.git/blob - src/support/Systemcall.cpp
038448b4f3d860e16ea54d9aac15105bee91dff0
[lyx.git] / src / support / Systemcall.cpp
1 /**
2  * \file Systemcall.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Asger Alstrup
7  *
8  * Interface cleaned up by
9  * \author Angus Leeming
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #include <config.h>
15
16 #include "support/Systemcall.h"
17 #include "support/os.h"
18
19 #include <cstdlib>
20
21 #include <QProcess>
22
23 using namespace std;
24
25 namespace lyx {
26 namespace support {
27
28 // Reuse of instance
29 int Systemcall::startscript(Starttype how, string const & what)
30 {
31         string command = what;
32
33         if (how == DontWait) {
34                 switch (os::shell()) {
35                 case os::UNIX:
36                         command += " &";
37                         break;
38                 case os::CMD_EXE:
39                         command = "start /min " + command;
40                         break;
41                 }
42         }
43
44 //#define DISABLE_EVALUATE_QPROCESS
45 #ifndef DISABLE_EVALUATE_QPROCESS
46         QString cmd = QString::fromLocal8Bit(command.c_str());
47         QProcess process;
48         process.start(cmd);
49         process.waitForFinished();
50         return process.exitCode();
51 #endif
52
53         return ::system(command.c_str());
54 }
55
56 } // namespace support
57 } // namespace lyx