Changeset 191


Ignore:
Timestamp:
Sep 23, 2009, 12:39:29 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

corelib: Oops, fixed regression of r190 (hang at application termination). Also repaced fcntl() with ioctl() calls as the former is known to not always work in kLIBC ~0.6.3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/corelib/io/qprocess_os2.cpp

    r190 r191  
    217217        QProcessManager *instance = QProcessManager::instance;
    218218        QProcessManager::instance = 0;
    219         // disable the signal handler
    220         while (!instance->eventSemGuard.testAndSetAcquire(1, 0))
    221             DosSleep(0);
    222         instance->uninstallSigHandler();
    223         // stop the thread
    224         instance->finish = true;
    225         locker.unlock();
    226         DosPostEventSem(instance->eventSem);
    227         instance->wait();
     219        // disable the signal handler and stop the thread if necessary
     220        if (instance->isRunning()) {
     221            Q_ASSERT(instance->eventSemGuard == 1 || instance->eventSemGuard == 2);
     222            while (!instance->eventSemGuard.testAndSetRelease(1, 0))
     223                DosSleep(0);
     224            instance->uninstallSigHandler();
     225            // stop the thread
     226            instance->finish = true;
     227            locker.unlock();
     228            DosPostEventSem(instance->eventSem);
     229            instance->wait();
     230        }
    228231        delete instance;
    229232    }
     
    661664                                       .arg(qPrintable(qt_error_string(errno))));
    662665        emit q->error(processError);
    663         removeProcess(q);
     666        removeProcess(q);
    664667        cleanup();
    665668        return;
     
    667670
    668671    this->pid = Q_PID(pid);
     672
     673
    669674
    670675    // close the ends we don't use and make all pipes non-blocking
     
    674679    }
    675680    if (stdinChannel.pipe[1] != -1)
    676         ::fcntl(stdinChannel.pipe[1], F_SETFL, ::fcntl(stdinChannel.pipe[1], F_GETFL) | O_NONBLOCK);
     681        ::);
    677682
    678683    if (stdoutChannel.pipe[1] != -1) {
     
    681686    }
    682687    if (stdoutChannel.pipe[0] != -1)
    683         ::fcntl(stdoutChannel.pipe[0], F_SETFL, ::fcntl(stdoutChannel.pipe[0], F_GETFL) | O_NONBLOCK);
     688        ::);
    684689
    685690    if (stderrChannel.pipe[1] != -1) {
     
    688693    }
    689694    if (stderrChannel.pipe[0] != -1)
    690         ::fcntl(stderrChannel.pipe[0], F_SETFL, ::fcntl(stderrChannel.pipe[0], F_GETFL) | O_NONBLOCK);
     695        ::);
    691696
    692697    // give the process a chance to start ...
Note: See TracChangeset for help on using the changeset viewer.