summaryrefslogtreecommitdiff
path: root/core/launcher/qprocess_unix.cpp
Unidiff
Diffstat (limited to 'core/launcher/qprocess_unix.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/qprocess_unix.cpp93
1 files changed, 46 insertions, 47 deletions
diff --git a/core/launcher/qprocess_unix.cpp b/core/launcher/qprocess_unix.cpp
index 19a8c93..d62e4e6 100644
--- a/core/launcher/qprocess_unix.cpp
+++ b/core/launcher/qprocess_unix.cpp
@@ -19,6 +19,4 @@
19**********************************************************************/ 19**********************************************************************/
20 20
21//#include "qplatformdefs.h"
22
23// Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED. 21// Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED.
24#if defined(connect) 22#if defined(connect)
@@ -28,18 +26,21 @@
28#include "qprocess.h" 26#include "qprocess.h"
29 27
30#ifndef QT_NO_PROCESS 28/* OPIE */
29#include <opie2/odebug.h>
30using namespace Opie::Core;
31 31
32#include "qapplication.h" 32/* QT */
33#include "qqueue.h" 33#ifndef QT_NO_PROCESS
34#include "qlist.h" 34#include <qapplication.h>
35#include "qsocketnotifier.h" 35#include <qqueue.h>
36#include "qtimer.h" 36#include <qlist.h>
37#include "qregexp.h" 37#include <qsocketnotifier.h>
38#include <qtimer.h>
39#include <qregexp.h>
38 40
39#include "qcleanuphandler_p.h" 41#include "qcleanuphandler_p.h"
40 42
43/* STD */
41#include <stdlib.h> 44#include <stdlib.h>
42
43// ### FOR Qt 2.3 compat
44#include <unistd.h> 45#include <unistd.h>
45#include <signal.h> 46#include <signal.h>
@@ -48,11 +49,9 @@
48#include <sys/wait.h> 49#include <sys/wait.h>
49#include <sys/fcntl.h> 50#include <sys/fcntl.h>
50 51#include <sys/resource.h>
51#include <errno.h> 52#include <errno.h>
52
53#ifdef Q_OS_MACX 53#ifdef Q_OS_MACX
54#include <sys/time.h> 54#include <sys/time.h>
55#endif 55#endif
56#include <sys/resource.h>
57 56
58#ifdef __MIPSEL__ 57#ifdef __MIPSEL__
@@ -133,5 +132,5 @@ public:
133 { 132 {
134#if defined(QT_QPROCESS_DEBUG) 133#if defined(QT_QPROCESS_DEBUG)
135 qDebug( "QProc: Constructor for pid %d and QProcess %p", pid, process ); 134 odebug << "QProc: Constructor for pid " << pid << " and QProcess " << process << "" << oendl;
136#endif 135#endif
137 socketStdin = 0; 136 socketStdin = 0;
@@ -142,5 +141,5 @@ public:
142 { 141 {
143#if defined(QT_QPROCESS_DEBUG) 142#if defined(QT_QPROCESS_DEBUG)
144 qDebug( "QProc: Destructor for pid %d and QProcess %p", pid, process ); 143 odebug << "QProc: Destructor for pid " << pid << " and QProcess " << process << "" << oendl;
145#endif 144#endif
146 if ( process != 0 ) { 145 if ( process != 0 ) {
@@ -214,5 +213,5 @@ QProcessManager::QProcessManager()
214 } else { 213 } else {
215#if defined(QT_QPROCESS_DEBUG) 214#if defined(QT_QPROCESS_DEBUG)
216 qDebug( "QProcessManager: install socket notifier (%d)", sigchldFd[1] ); 215 odebug << "QProcessManager: install socket notifier (" << sigchldFd[1] << ")" << oendl;
217#endif 216#endif
218 QSocketNotifier *sn = new QSocketNotifier( sigchldFd[1], 217 QSocketNotifier *sn = new QSocketNotifier( sigchldFd[1],
@@ -227,5 +226,5 @@ QProcessManager::QProcessManager()
227 226
228#if defined(QT_QPROCESS_DEBUG) 227#if defined(QT_QPROCESS_DEBUG)
229 qDebug( "QProcessManager: install a SIGCHLD handler" ); 228 odebug << "QProcessManager: install a SIGCHLD handler" << oendl;
230#endif 229#endif
231 act.sa_handler = qt_C_sigchldHnd; 230 act.sa_handler = qt_C_sigchldHnd;
@@ -237,8 +236,8 @@ QProcessManager::QProcessManager()
237#endif 236#endif
238 if ( sigaction( SIGCHLD, &act, &oldactChld ) != 0 ) 237 if ( sigaction( SIGCHLD, &act, &oldactChld ) != 0 )
239 qWarning( "Error installing SIGCHLD handler" ); 238 owarn << "Error installing SIGCHLD handler" << oendl;
240 239
241#if defined(QT_QPROCESS_DEBUG) 240#if defined(QT_QPROCESS_DEBUG)
242 qDebug( "QProcessManager: install a SIGPIPE handler (SIG_IGN)" ); 241 odebug << "QProcessManager: install a SIGPIPE handler (SIG_IGN)" << oendl;
243#endif 242#endif
244 /* 243 /*
@@ -253,5 +252,5 @@ QProcessManager::QProcessManager()
253 act.sa_flags = 0; 252 act.sa_flags = 0;
254 if ( sigaction( SIGPIPE, &act, &oldactPipe ) != 0 ) 253 if ( sigaction( SIGPIPE, &act, &oldactPipe ) != 0 )
255 qWarning( "Error installing SIGPIPE handler" ); 254 owarn << "Error installing SIGPIPE handler" << oendl;
256} 255}
257 256
@@ -267,14 +266,14 @@ QProcessManager::~QProcessManager()
267 // restore SIGCHLD handler 266 // restore SIGCHLD handler
268#if defined(QT_QPROCESS_DEBUG) 267#if defined(QT_QPROCESS_DEBUG)
269 qDebug( "QProcessManager: restore old sigchild handler" ); 268 odebug << "QProcessManager: restore old sigchild handler" << oendl;
270#endif 269#endif
271 if ( sigaction( SIGCHLD, &oldactChld, 0 ) != 0 ) 270 if ( sigaction( SIGCHLD, &oldactChld, 0 ) != 0 )
272 qWarning( "Error restoring SIGCHLD handler" ); 271 owarn << "Error restoring SIGCHLD handler" << oendl;
273 272
274#if defined(QT_QPROCESS_DEBUG) 273#if defined(QT_QPROCESS_DEBUG)
275 qDebug( "QProcessManager: restore old sigpipe handler" ); 274 odebug << "QProcessManager: restore old sigpipe handler" << oendl;
276#endif 275#endif
277 if ( sigaction( SIGPIPE, &oldactPipe, 0 ) != 0 ) 276 if ( sigaction( SIGPIPE, &oldactPipe, 0 ) != 0 )
278 qWarning( "Error restoring SIGPIPE handler" ); 277 owarn << "Error restoring SIGPIPE handler" << oendl;
279} 278}
280 279
@@ -283,5 +282,5 @@ void QProcessManager::append( QProc *p )
283 procList->append( p ); 282 procList->append( p );
284#if defined(QT_QPROCESS_DEBUG) 283#if defined(QT_QPROCESS_DEBUG)
285 qDebug( "QProcessManager: append process (procList.count(): %d)", procList->count() ); 284 odebug << "QProcessManager: append process (procList.count(): " << procList->count() << ")" << oendl;
286#endif 285#endif
287} 286}
@@ -291,5 +290,5 @@ void QProcessManager::remove( QProc *p )
291 procList->remove( p ); 290 procList->remove( p );
292#if defined(QT_QPROCESS_DEBUG) 291#if defined(QT_QPROCESS_DEBUG)
293 qDebug( "QProcessManager: remove process (procList.count(): %d)", procList->count() ); 292 odebug << "QProcessManager: remove process (procList.count(): " << procList->count() << ")" << oendl;
294#endif 293#endif
295 cleanup(); 294 cleanup();
@@ -317,5 +316,5 @@ void QProcessManager::sigchldHnd( int fd )
317 ::read( fd, &tmp, sizeof(tmp) ); 316 ::read( fd, &tmp, sizeof(tmp) );
318#if defined(QT_QPROCESS_DEBUG) 317#if defined(QT_QPROCESS_DEBUG)
319 qDebug( "QProcessManager::sigchldHnd()" ); 318 odebug << "QProcessManager::sigchldHnd()" << oendl;
320#endif 319#endif
321 QProc *proc; 320 QProc *proc;
@@ -330,5 +329,5 @@ void QProcessManager::sigchldHnd( int fd )
330 if ( !process->isRunning() ) { 329 if ( !process->isRunning() ) {
331#if defined(QT_QPROCESS_DEBUG) 330#if defined(QT_QPROCESS_DEBUG)
332 qDebug( "QProcessManager::sigchldHnd() (PID: %d): process exited (QProcess available)", proc->pid ); 331 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): process exited (QProcess available)" << oendl;
333#endif 332#endif
334 // read pending data 333 // read pending data
@@ -336,5 +335,5 @@ void QProcessManager::sigchldHnd( int fd )
336 if ( ::ioctl(proc->socketStdout, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { 335 if ( ::ioctl(proc->socketStdout, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) {
337#if defined(QT_QPROCESS_DEBUG) 336#if defined(QT_QPROCESS_DEBUG)
338 qDebug( "QProcessManager::sigchldHnd() (PID: %d): reading %d bytes of pending data on stdout", proc->pid, nbytes ); 337 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): reading " << nbytes << " bytes of pending data on stdout" << oendl;
339#endif 338#endif
340 process->socketRead( proc->socketStdout ); 339 process->socketRead( proc->socketStdout );
@@ -343,5 +342,5 @@ void QProcessManager::sigchldHnd( int fd )
343 if ( ::ioctl(proc->socketStderr, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { 342 if ( ::ioctl(proc->socketStderr, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) {
344#if defined(QT_QPROCESS_DEBUG) 343#if defined(QT_QPROCESS_DEBUG)
345 qDebug( "QProcessManager::sigchldHnd() (PID: %d): reading %d bytes of pending data on stderr", proc->pid, nbytes ); 344 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): reading " << nbytes << " bytes of pending data on stderr" << oendl;
346#endif 345#endif
347 process->socketRead( proc->socketStderr ); 346 process->socketRead( proc->socketStderr );
@@ -357,5 +356,5 @@ void QProcessManager::sigchldHnd( int fd )
357 if ( ::waitpid( proc->pid, &status, WNOHANG ) == proc->pid ) { 356 if ( ::waitpid( proc->pid, &status, WNOHANG ) == proc->pid ) {
358#if defined(QT_QPROCESS_DEBUG) 357#if defined(QT_QPROCESS_DEBUG)
359 qDebug( "QProcessManager::sigchldHnd() (PID: %d): process exited (QProcess not available)", proc->pid ); 358 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): process exited (QProcess not available)" << oendl;
360#endif 359#endif
361 removeProc = TRUE; 360 removeProc = TRUE;
@@ -387,5 +386,5 @@ QProcessPrivate::QProcessPrivate()
387{ 386{
388#if defined(QT_QPROCESS_DEBUG) 387#if defined(QT_QPROCESS_DEBUG)
389 qDebug( "QProcessPrivate: Constructor" ); 388 odebug << "QProcessPrivate: Constructor" << oendl;
390#endif 389#endif
391 stdinBufRead = 0; 390 stdinBufRead = 0;
@@ -404,5 +403,5 @@ QProcessPrivate::~QProcessPrivate()
404{ 403{
405#if defined(QT_QPROCESS_DEBUG) 404#if defined(QT_QPROCESS_DEBUG)
406 qDebug( "QProcessPrivate: Destructor" ); 405 odebug << "QProcessPrivate: Destructor" << oendl;
407#endif 406#endif
408 407
@@ -600,5 +599,5 @@ bool QProcess::start( QStringList *env )
600{ 599{
601#if defined(QT_QPROCESS_DEBUG) 600#if defined(QT_QPROCESS_DEBUG)
602 qDebug( "QProcess::start()" ); 601 odebug << "QProcess::start()" << oendl;
603#endif 602#endif
604 reset(); 603 reset();
@@ -636,5 +635,5 @@ bool QProcess::start( QStringList *env )
636 arglist[i] = arglistQ[i]; 635 arglist[i] = arglistQ[i];
637#if defined(QT_QPROCESS_DEBUG) 636#if defined(QT_QPROCESS_DEBUG)
638 qDebug( "QProcess::start(): arg %d = %s", i, arglist[i] ); 637 odebug << "QProcess::start(): arg " << i << " = " << arglist[i] << "" << oendl;
639#endif 638#endif
640 i++; 639 i++;
@@ -800,5 +799,5 @@ bool QProcess::start( QStringList *env )
800error: 799error:
801#if defined(QT_QPROCESS_DEBUG) 800#if defined(QT_QPROCESS_DEBUG)
802 qDebug( "QProcess::start(): error starting process" ); 801 odebug << "QProcess::start(): error starting process" << oendl;
803#endif 802#endif
804 if ( d->procManager ) 803 if ( d->procManager )
@@ -879,5 +878,5 @@ bool QProcess::isRunning() const
879 if ( d->exitValuesCalculated ) { 878 if ( d->exitValuesCalculated ) {
880#if defined(QT_QPROCESS_DEBUG) 879#if defined(QT_QPROCESS_DEBUG)
881 qDebug( "QProcess::isRunning(): FALSE (already computed)" ); 880 odebug << "QProcess::isRunning(): FALSE (already computed)" << oendl;
882#endif 881#endif
883 return FALSE; 882 return FALSE;
@@ -896,10 +895,10 @@ bool QProcess::isRunning() const
896 d->exitValuesCalculated = TRUE; 895 d->exitValuesCalculated = TRUE;
897#if defined(QT_QPROCESS_DEBUG) 896#if defined(QT_QPROCESS_DEBUG)
898 qDebug( "QProcess::isRunning() (PID: %d): FALSE", d->proc->pid ); 897 odebug << "QProcess::isRunning() (PID: " << d->proc->pid << "): FALSE" << oendl;
899#endif 898#endif
900 return FALSE; 899 return FALSE;
901 } 900 }
902#if defined(QT_QPROCESS_DEBUG) 901#if defined(QT_QPROCESS_DEBUG)
903 qDebug( "QProcess::isRunning() (PID: %d): TRUE", d->proc->pid ); 902 odebug << "QProcess::isRunning() (PID: " << d->proc->pid << "): TRUE" << oendl;
904#endif 903#endif
905 return TRUE; 904 return TRUE;
@@ -921,5 +920,5 @@ void QProcess::writeToStdin( const QByteArray& buf )
921{ 920{
922#if defined(QT_QPROCESS_DEBUG) 921#if defined(QT_QPROCESS_DEBUG)
923// qDebug( "QProcess::writeToStdin(): write to stdin (%d)", d->socketStdin ); 922// odebug << "QProcess::writeToStdin(): write to stdin (" << d->socketStdin << ")" << oendl;
924#endif 923#endif
925 d->stdinBuf.enqueue( new QByteArray(buf) ); 924 d->stdinBuf.enqueue( new QByteArray(buf) );
@@ -948,8 +947,8 @@ void QProcess::closeStdin()
948 d->notifierStdin = 0; 947 d->notifierStdin = 0;
949 if ( ::close( d->proc->socketStdin ) != 0 ) { 948 if ( ::close( d->proc->socketStdin ) != 0 ) {
950 qWarning( "Could not close stdin of child process" ); 949 owarn << "Could not close stdin of child process" << oendl;
951 } 950 }
952#if defined(QT_QPROCESS_DEBUG) 951#if defined(QT_QPROCESS_DEBUG)
953 qDebug( "QProcess::closeStdin(): stdin (%d) closed", d->proc->socketStdin ); 952 odebug << "QProcess::closeStdin(): stdin (" << d->proc->socketStdin << ") closed" << oendl;
954#endif 953#endif
955 d->proc->socketStdin = 0; 954 d->proc->socketStdin = 0;
@@ -971,5 +970,5 @@ void QProcess::socketRead( int fd )
971 } 970 }
972#if defined(QT_QPROCESS_DEBUG) 971#if defined(QT_QPROCESS_DEBUG)
973 qDebug( "QProcess::socketRead(): %d", fd ); 972 odebug << "QProcess::socketRead(): " << fd << "" << oendl;
974#endif 973#endif
975 if ( fd == 0 ) 974 if ( fd == 0 )
@@ -1000,5 +999,5 @@ void QProcess::socketRead( int fd )
1000 if ( fd == d->proc->socketStdout ) { 999 if ( fd == d->proc->socketStdout ) {
1001#if defined(QT_QPROCESS_DEBUG) 1000#if defined(QT_QPROCESS_DEBUG)
1002 qDebug( "QProcess::socketRead(): stdout (%d) closed", fd ); 1001 odebug << "QProcess::socketRead(): stdout (" << fd << ") closed" << oendl;
1003#endif 1002#endif
1004 d->notifierStdout->setEnabled( FALSE ); 1003 d->notifierStdout->setEnabled( FALSE );
@@ -1010,5 +1009,5 @@ void QProcess::socketRead( int fd )
1010 } else if ( fd == d->proc->socketStderr ) { 1009 } else if ( fd == d->proc->socketStderr ) {
1011#if defined(QT_QPROCESS_DEBUG) 1010#if defined(QT_QPROCESS_DEBUG)
1012 qDebug( "QProcess::socketRead(): stderr (%d) closed", fd ); 1011 odebug << "QProcess::socketRead(): stderr (" << fd << ") closed" << oendl;
1013#endif 1012#endif
1014 d->notifierStderr->setEnabled( FALSE ); 1013 d->notifierStderr->setEnabled( FALSE );
@@ -1062,5 +1061,5 @@ void QProcess::socketWrite( int fd )
1062 } 1061 }
1063#if defined(QT_QPROCESS_DEBUG) 1062#if defined(QT_QPROCESS_DEBUG)
1064 qDebug( "QProcess::socketWrite(): write to stdin (%d)", fd ); 1063 odebug << "QProcess::socketWrite(): write to stdin (" << fd << ")" << oendl;
1065#endif 1064#endif
1066 ssize_t ret = ::write( fd, 1065 ssize_t ret = ::write( fd,