27 #include <qapplication.h>
28 #include <qeventloop.h>
29 #include <qfileinfo.h>
36 mProcessAppEvents =
true;
39 connect(
this, SIGNAL(wroteToStdin()),
this, SLOT(ourProcGotOurStdinData()));
40 connect(
this, SIGNAL(processExited()),
this, SLOT(ourProcExited()));
49 void KLFBlockProcess::ourProcGotOurStdinData()
51 #ifndef KLFBACKEND_QT4
56 void KLFBlockProcess::ourProcExited()
60 #ifndef KLFBACKEND_QT4
79 #if defined(Q_OS_UNIX) && defined(KLFBACKEND_QT4)
89 if (!fpeek.
open(QIODevice::ReadOnly)) {
94 bool isbinary =
false;
95 while (n++ < 3 && (line = fpeek.readLine()).size()) {
96 for (j = 0; j < line.
size(); ++j) {
97 if ( ! isascii(line[j]) ) {
107 cmd.prepend(
"/usr/bin/env");
120 #ifdef KLFBACKEND_QT4
121 if (env.size() > 0) {
126 args.erase(args.begin());
128 start(program, args);
148 writeToStdin(stdindata);
152 #ifdef KLFBACKEND_QT4
153 if (mProcessAppEvents) {
154 while (_runstatus == 0) {
155 qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
159 klfDbg(
"Can't wait for finished!");
163 klfDbg(
"Process should have finished now.");
165 while (_runstatus == 0) {
166 qApp->processEvents(QEventLoop::ExcludeUserInput);
170 if (_runstatus < 0) {
171 klfDbg(
"some error occurred, _runstatus="+
QString(
"%1").arg(_runstatus)) ;
183 #ifdef KLFBACKEND_QT4
186 extern char ** environ;
188 for (k = 0; environ[k] != NULL; ++k) {
192 return curenvironment;
Defines the KLFBlockProcess class.
#define klfDbg(streamableItems)
print debug stream items
bool startProcess(QStringList cmd, QByteArray stdindata, QStringList env=QStringList())
KLFBlockProcess(QObject *parent=0)
fromLocal8Bit(const char *str, int size=-1)
finished(int exitCode, QProcess::ExitStatus exitStatus)
KLF_EXPORT QString klfSearchPath(const QString &prog, const QString &extra_path="")
Smart executable searching in a given path list with wildcards.
KLF_EXPORT QStringList klf_cur_environ()
The current process environment.
setEnvironment(const QStringList &environment)
waitForStarted(int msecs=30000)
#define KLF_ASSERT_CONDITION(expr, msg, failaction)
Asserting Conditions (NON-FATAL)
ExitStatusQProcess::exitStatus()
start(const QString &program, const QStringList &arguments, OpenMode mode=ReadWrite)
waitForFinished(int msecs=30000)