25 #include <qapplication.h>
26 #include <qeventloop.h>
27 #include <qfileinfo.h>
34 mProcessAppEvents =
true;
37 connect(
this, SIGNAL(wroteToStdin()),
this, SLOT(ourProcGotOurStdinData()));
38 connect(
this, SIGNAL(processExited()),
this, SLOT(ourProcExited()));
47 void KLFBlockProcess::ourProcGotOurStdinData()
49 #ifndef KLFBACKEND_QT4
54 void KLFBlockProcess::ourProcExited()
58 #ifndef KLFBACKEND_QT4
71 klfDbg(
"Running: "<<cmd<<
", stdindata/size="<<stdindata.
size());
77 #if defined(Q_OS_UNIX) && defined(KLFBACKEND_QT4)
84 fn = klfSearchPath(cmd[0]);
86 if (!fpeek.
open(QIODevice::ReadOnly)) {
87 klfDbg(
"cmd[0]="<<cmd[0]<<
", Can't peek into file "<<fn<<
"!") ;
91 bool isbinary =
false;
92 while (n++ < 3 && (line = fpeek.readLine()).size()) {
93 for (j = 0; j < line.
size(); ++j) {
94 if ((
int)line[j] > 127 || (int)line[j] < 0) {
114 klfDbg(
"Running cmd="<<cmd);
117 #ifdef KLFBACKEND_QT4
118 if (env.size() > 0) {
123 args.erase(args.begin());
124 klfDbg(
"Starting "<<program<<
", "<<args) ;
125 start(program, args);
127 klfDbg(
"Can't wait for started! Error="<<
error()) ;
134 klfDbg(
"wrote input data (size="<<stdindata.
size()<<
")") ;
145 writeToStdin(stdindata);
149 #ifdef KLFBACKEND_QT4
150 if (mProcessAppEvents) {
151 while (_runstatus == 0) {
152 qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
156 klfDbg(
"Can't wait for finished!");
160 klfDbg(
"Process should have finished now.");
162 while (_runstatus == 0) {
163 qApp->processEvents(QEventLoop::ExcludeUserInput);
167 if (_runstatus < 0) {
168 klfDbg(
"some error occurred, _runstatus="<<_runstatus) ;
180 #ifdef KLFBACKEND_QT4
183 extern char ** environ;
185 for (k = 0; environ[k] != NULL; ++k) {
189 return curenvironment;