Changeset 699 for trunk/src/corelib/io/qprocess_os2.cpp
- Timestamp:
- Mar 18, 2010, 3:42:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/io/qprocess_os2.cpp
r690 r699 43 43 44 44 //#define QPROCESS_DEBUG 45 #include "qdebug.h"46 45 47 46 #if defined(__INNOTEK_LIBC__) … … 52 51 53 52 #if defined QPROCESS_DEBUG 53 54 54 #include "qstring.h" 55 55 #include <ctype.h> … … 86 86 return out; 87 87 } 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 88 103 QT_END_NAMESPACE 104 105 106 107 89 108 #endif 90 109 … … 246 265 USHORT QProcessManager::addProcess(QProcess *process) 247 266 { 248 #if defined (QPROCESS_DEBUG) 249 qDebug("QProcessManager::addProcess(%p)", process); 250 #endif 267 DEBUG(("QProcessManager::addProcess(%p)", process)); 251 268 252 269 QMutexLocker locker(&mutex); … … 317 334 QProcess *process = instance->processes[procKey]; 318 335 319 #if defined (QPROCESS_DEBUG) 320 qDebug("QProcessManager::removeProcess(%p)", process); 321 #endif 336 DEBUG(("QProcessManager::removeProcess(%p)", process)); 322 337 323 338 // to guarantee that the given procKey may be reused, we must close all … … 339 354 : refcnt(0), finish(false), eventSem(NULLHANDLE), sa_old_sigchld_handler(0) 340 355 { 341 #if defined (QPROCESS_DEBUG) 342 qDebug() << "QProcessManager::QProcessManager()"; 343 #endif 356 DEBUG(() << "QProcessManager::QProcessManager()"); 344 357 345 358 APIRET rc = DosCreateEventSem(NULL, &eventSem, … … 354 367 QProcessManager::~QProcessManager() 355 368 { 356 #if defined (QPROCESS_DEBUG) 357 qDebug() << "QProcessManager::~QProcessManager()"; 358 #endif 369 DEBUG(() << "QProcessManager::~QProcessManager()"); 359 370 360 371 Q_ASSERT(!refcnt); … … 393 404 void QProcessManager::run() 394 405 { 395 #if defined (QPROCESS_DEBUG) 396 qDebug() << "QProcessManager::run() BEGIN"; 397 #endif 406 DEBUG(() << "QProcessManager::run() BEGIN"); 398 407 399 408 // Note: the rationale behind using a worker thread so far is that … … 419 428 420 429 if (instance->deathFlag.testAndSetRelaxed(1, 0)) { 421 #if defined (QPROCESS_DEBUG) 422 qDebug() << "QProcessManager::run(): child death signaled"; 423 #endif 430 DEBUG(() << "QProcessManager::run(): child death signaled"); 424 431 foreach (QProcess *proc, processes) { 425 432 QProcessPrivate::WaitMode mode = (QProcessPrivate::WaitMode) … … 442 449 continue; 443 450 444 #if defined (QPROCESS_DEBUG) 445 qDebug() << "QProcessManager::run(): checking pipes"; 446 #endif 451 DEBUG(() << "QProcessManager::run(): checking pipes"); 447 452 448 453 // make sure the state array is big enough. The best size for sz pipes … … 477 482 if (pass == 1 && status != NPSS_CLOSE) 478 483 continue; 479 #if defined(QPROCESS_DEBUG) 480 qDebug(" %d/%d: fStatus %u fFlag f%02X usKey %04hX usAvail %hu", 484 DEBUG((" %d/%d: fStatus %u fFlag f%02X usKey %04hX usAvail %hu", 481 485 pass, i, (uint) pipeStates[i].fStatus, 482 486 (uint) pipeStates[i].fFlag, pipeStates[i].usKey, 483 pipeStates[i].usAvail); 484 #endif 487 pipeStates[i].usAvail)); 485 488 int procKey = toProcKey(pipeStates[i].usKey); 486 489 QProcessPrivate::PipeType type = toPipeType(pipeStates[i].usKey); … … 488 491 QProcess *proc = processes[procKey]; 489 492 Q_ASSERT(proc); 490 #if defined(QPROCESS_DEBUG) 491 qDebug(" process %p", proc); 492 #endif 493 DEBUG((" process %p", proc)); 493 494 QProcessPrivate *d = proc->d_func(); 494 495 … … 538 539 ::free(pipeStates); 539 540 540 #if defined (QPROCESS_DEBUG) 541 qDebug() << "QProcessManager::run() END"; 542 #endif 541 DEBUG(() << "QProcessManager::run() END"); 543 542 } 544 543 … … 830 829 } 831 830 832 #if defined(QPROCESS_DEBUG) 833 qDebug("qt_startProcess: workdir is \"%s\"", qPrintable(QDir::currentPath())); 834 #endif 831 DEBUG(("qt_startProcess: workdir is \"%s\"", qPrintable(QDir::currentPath()))); 835 832 836 833 // try to find the executable … … 883 880 } 884 881 885 #if defined(QPROCESS_DEBUG) 886 qDebug("qt_startProcess: found \"%s\" for \"%s\"", 882 DEBUG(("qt_startProcess: found \"%s\" for \"%s\"", 887 883 qPrintable(QFile::decodeName(fullProgramName)), 888 qPrintable(QFile::decodeName(programName))); 889 #endif 884 qPrintable(QFile::decodeName(programName)))); 890 885 891 886 int pid = -1; … … 910 905 paths = path.split(QLatin1Char(';'), QString::SkipEmptyParts); 911 906 if (paths.contains(fullPath, Qt::CaseInsensitive)) { 912 #if defined(QPROCESS_DEBUG) 913 qDebug("qt_startProcess: \"%s\" is already in BEGINLIBPATH", 914 qPrintable(fullPath)); 915 #endif 907 DEBUG(("qt_startProcess: \"%s\" is already in BEGINLIBPATH", 908 qPrintable(fullPath))); 916 909 } else { 917 #if defined(QPROCESS_DEBUG) 918 qDebug("qt_startProcess: prepending \"%s\" to BEGINLIBPATH", 919 qPrintable(fullPath)); 920 #endif 910 DEBUG(("qt_startProcess: prepending \"%s\" to BEGINLIBPATH", 911 qPrintable(fullPath))); 921 912 prependedLibPath = true; 922 913 QByteArray newLibPath = libPathBuf; … … 961 952 962 953 #if defined(QPROCESS_DEBUG) 963 qDebug("qt_startProcess: executable \"%s\"",964 qPrintable(QFile::decodeName(programReal))) ;954 ("qt_startProcess: executable \"%s\"", 955 qPrintable(QFile::decodeName(programReal))); 965 956 for (int i = 0; argvReal[i]; ++i) { 966 qDebug("qt_startProcess: arg[%d] \"%s\"",967 i, qPrintable(QFile::decodeName(argvReal[i]))) ;957 ("qt_startProcess: arg[%d] \"%s\"", 958 i, qPrintable(QFile::decodeName(argvReal[i]))); 968 959 } 969 960 #endif … … 1042 1033 ULONG ulSid, ulPidDummy; 1043 1034 arc = DosStartSession(&data, &ulSid, &ulPidDummy); 1044 #if defined(QPROCESS_DEBUG) 1045 qDebug("qt_startProcess: DosStartSession() returned %ld", arc); 1046 #endif 1035 DEBUG(("qt_startProcess: DosStartSession() returned %ld", arc)); 1047 1036 // Note: for SSF_RELATED_INDEPENDENT, PID of the started process is 1048 1037 // unknown, return 0 to indicate this … … 1062 1051 } 1063 1052 1064 #if defined(QPROCESS_DEBUG) 1065 qDebug("qt_startProcess: pid %d", pid); 1066 #endif 1053 DEBUG(("qt_startProcess: pid %d", pid)); 1067 1054 1068 1055 if (prependedLibPath) { … … 1092 1079 Q_Q(QProcess); 1093 1080 1094 #if defined (QPROCESS_DEBUG) 1095 qDebug("QProcessPrivate::startProcess"); 1096 #endif 1081 DEBUG(("QProcessPrivate::startProcess")); 1097 1082 1098 1083 // Initialize pipes … … 1143 1128 } 1144 1129 if (arc != NO_ERROR) { 1145 #if defined (QPROCESS_DEBUG) 1146 qDebug("QProcessPrivate::startProcess: DosDupHandle for STDIN " 1147 "returned %lu", arc); 1148 #endif 1130 DEBUG(("QProcessPrivate::startProcess: DosDupHandle for STDIN " 1131 "returned %lu", arc)); 1149 1132 break; 1150 1133 } … … 1168 1151 } 1169 1152 if (arc != NO_ERROR) { 1170 #if defined (QPROCESS_DEBUG) 1171 qDebug("QProcessPrivate::startProcess: DosDupHandle for STDOUT " 1172 "returned %lu", arc); 1173 #endif 1153 DEBUG(("QProcessPrivate::startProcess: DosDupHandle for STDOUT " 1154 "returned %lu", arc)); 1174 1155 break; 1175 1156 } … … 1179 1160 arc = DosDupHandle(realStdout, &realStderr); 1180 1161 } else { 1181 // qDebug() uses STDERR so only redirect if !QPROCESS_DEBUG1182 #if !defined (QPROCESS_DEBUG)1183 1162 arc = DosDupHandle(stderrChannel.pipe.client, &realStderr); 1184 #endif1185 1163 } 1186 1164 } … … 1221 1199 .arg(arc))); 1222 1200 } else { 1223 #if defined (QPROCESS_DEBUG) 1224 qDebug("spawnvpe failed: %s", qPrintable(qt_error_string(errno))); 1225 #endif 1201 DEBUG(("spawnvpe failed: %s", qPrintable(qt_error_string(errno)))); 1226 1202 q->setErrorString(QProcess::tr("Process failed to start: %1") 1227 1203 .arg(qt_error_string(errno))); … … 1317 1293 that->pipeData[OutPipe].bytesLeft = newBytes; 1318 1294 1319 #if defined (QPROCESS_DEBUG) 1320 qDebug("QProcessPrivate::bytesAvailableFromStdout() == %lld", 1321 that->pipeData[OutPipe].bytesLeft); 1322 #endif 1295 DEBUG(("QProcessPrivate::bytesAvailableFromStdout() == %lld", 1296 that->pipeData[OutPipe].bytesLeft)); 1323 1297 return that->pipeData[OutPipe].bytesLeft; 1324 1298 } … … 1352 1326 that->pipeData[ErrPipe].bytesLeft = newBytes; 1353 1327 1354 #if defined (QPROCESS_DEBUG) 1355 qDebug("QProcessPrivate::bytesAvailableFromStderr() == %lld", 1356 that->pipeData[ErrPipe].bytesLeft); 1357 #endif 1328 DEBUG(("QProcessPrivate::bytesAvailableFromStderr() == %lld", 1329 that->pipeData[ErrPipe].bytesLeft)); 1358 1330 return that->pipeData[ErrPipe].bytesLeft; 1359 1331 } … … 1372 1344 } 1373 1345 1374 #if defined QPROCESS_DEBUG 1375 qDebug("QProcessPrivate::readFromStdout(%p \"%s\", %lld) == %lld", 1376 data, qt_prettyDebug(data, bytesRead, 16).constData(), maxlen, bytesRead); 1377 #endif 1346 DEBUG(("QProcessPrivate::readFromStdout(%p \"%s\", %lld) == %lld", 1347 data, qt_prettyDebug(data, bytesRead, 16).constData(), maxlen, bytesRead)); 1378 1348 return bytesRead; 1379 1349 } … … 1392 1362 } 1393 1363 1394 #if defined QPROCESS_DEBUG 1395 qDebug("QProcessPrivate::readFromStderr(%p \"%s\", %lld) == %lld", 1396 data, qt_prettyDebug(data, bytesRead, 16).constData(), maxlen, bytesRead); 1397 #endif 1364 DEBUG(("QProcessPrivate::readFromStderr(%p \"%s\", %lld) == %lld", 1365 data, qt_prettyDebug(data, bytesRead, 16).constData(), maxlen, bytesRead)); 1398 1366 return bytesRead; 1399 1367 } … … 1408 1376 that->pipeData[InPipe].bytesLeft = newBytes; 1409 1377 1410 #if defined (QPROCESS_DEBUG) 1411 qDebug("QProcessPrivate::writeToStdin(): %lld free bytes in pipe", 1412 that->pipeData[InPipe].bytesLeft); 1413 #endif 1378 DEBUG(("QProcessPrivate::writeToStdin(): %lld free bytes in pipe", 1379 that->pipeData[InPipe].bytesLeft)); 1414 1380 if (!that->pipeData[InPipe].bytesLeft) 1415 1381 return 0; … … 1426 1392 } 1427 1393 1428 #if defined QPROCESS_DEBUG 1429 qDebug("QProcessPrivate::writeToStdin(%p \"%s\", %lld) == %lld", 1430 data, qt_prettyDebug(data, maxlen, 16).constData(), maxlen, written); 1431 #endif 1394 DEBUG(("QProcessPrivate::writeToStdin(%p \"%s\", %lld) == %lld", 1395 data, qt_prettyDebug(data, maxlen, 16).constData(), maxlen, written)); 1432 1396 return written; 1433 1397 } … … 1435 1399 void QProcessPrivate::terminateProcess() 1436 1400 { 1437 #if defined (QPROCESS_DEBUG) 1438 qDebug("QProcessPrivate::terminateProcess()"); 1439 #endif 1401 DEBUG(("QProcessPrivate::terminateProcess()")); 1440 1402 if (pid) { 1441 1403 HSWITCH hswitch = WinQuerySwitchHandle(NULL, pid); … … 1466 1428 void QProcessPrivate::killProcess() 1467 1429 { 1468 #if defined (QPROCESS_DEBUG) 1469 qDebug("QProcessPrivate::killProcess()"); 1470 #endif 1430 DEBUG(("QProcessPrivate::killProcess()")); 1471 1431 if (pid) 1472 1432 DosKillProcess(DKP_PROCESS, pid); … … 1504 1464 { 1505 1465 Q_Q(QProcess); 1506 #if defined (QPROCESS_DEBUG) 1507 qDebug("QProcessPrivate::waitForReadyRead(%d)", msecs); 1508 #endif 1466 DEBUG(("QProcessPrivate::waitForReadyRead(%d)", msecs)); 1509 1467 1510 1468 QTime stopWatch; … … 1570 1528 { 1571 1529 Q_Q(QProcess); 1572 #if defined (QPROCESS_DEBUG) 1573 qDebug("QProcessPrivate::waitForBytesWritten(%d)", msecs); 1574 #endif 1530 DEBUG(("QProcessPrivate::waitForBytesWritten(%d)", msecs)); 1575 1531 1576 1532 QTime stopWatch; … … 1629 1585 { 1630 1586 Q_Q(QProcess); 1631 #if defined (QPROCESS_DEBUG) 1632 qDebug("QProcessPrivate::waitForFinished(%d)", msecs); 1633 #endif 1587 DEBUG(("QProcessPrivate::waitForFinished(%d)", msecs)); 1634 1588 1635 1589 QTime stopWatch; … … 1724 1678 crashed = !WIFEXITED(exitStatus); 1725 1679 exitCode = WEXITSTATUS(exitStatus); 1680 1681 1682 1683 1726 1684 #if defined QPROCESS_DEBUG 1727 qDebug() << "QProcessPrivate::waitForDeadChild() dead with exitCode" 1728 << exitCode << ", crashed?" << crashed; 1729 #endif 1730 return true; 1731 } 1732 #if defined QPROCESS_DEBUG 1733 qDebug() << "QProcessPrivate::waitForDeadChild() not dead!"; 1685 DEBUG(() << "QProcessPrivate::waitForDeadChild() not dead!"); 1734 1686 if (waitResult == -1) 1735 qDebug() << "QProcessPrivate::waitForDeadChild()" << strerror(errno);1687 ); 1736 1688 #endif 1737 1689 return false;
Note:
See TracChangeset
for help on using the changeset viewer.