Changeset 73


Ignore:
Timestamp:
Jul 9, 2009, 2:16:47 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

corelib: OS/2: Implemented QProcess::startDetached().

File:
1 edited

Legend:

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

    r72 r73  
    243243}
    244244
    245 void QProcessPrivate::startProcess()
    246 {
    247     Q_Q(QProcess);
    248 
    249 #if defined (QPROCESS_DEBUG)
    250     qDebug("QProcessPrivate::startProcess()");
    251 #endif
    252 
    253     // Initialize pipes
    254     if (!createChannel(stdinChannel) ||
    255         !createChannel(stdoutChannel) ||
    256         !createChannel(stderrChannel))
    257         return;
    258 
    259     // Start the process (platform dependent)
    260     q->setProcessState(QProcess::Starting);
    261 
    262     // save & copy the stdin socket
    263     int stdin_copy = ::dup(fileno(stdin));
    264     ::dup2(stdinChannel.pipe[0], fileno(stdin));
    265 
    266     // save & copy the stdout and stderr if asked to
    267     int stdout_copy = -1, stderr_copy = -1;
    268     if (processChannelMode != QProcess::ForwardedChannels) {
    269         stdout_copy = ::dup(fileno(stdout));
    270         ::dup2(stdoutChannel.pipe[1], fileno(stdout));
    271 
    272         // merge stdout and stderr if asked to
    273         stderr_copy = ::dup(fileno(stderr));
    274         if (processChannelMode == QProcess::MergedChannels) {
    275             ::dup2(fileno(stdout), fileno(stderr));
    276         } else {
    277             ::dup2(stderrChannel.pipe[1], fileno(stderr));
    278         }
    279     }
     245static int qt_startProcess(const QString &program, const QStringList &arguments,
     246                           const QString &workingDirectory,
     247                           const QStringList *environment, bool detached = false)
     248{
     249    int mode = detached ? P_DETACH : P_NOWAIT;
    280250
    281251    // Create argument list with right number of elements, and set the final
     
    299269    int envc = 0;
    300270    char **envv;
    301     if (environment.count()) {
     271    if (environmentcount()) {
    302272        bool seenPATH = false;
    303273        bool seenCOMSPEC = false;
    304274
    305         envv = new char *[environment.count() + 1 + 2 /* may be PATH + COMSPEC */];
    306         for (; envc < environment.count(); ++envc) {
    307             QString item = environment.at(envc);
     275        envv = new char *[environmentcount() + 1 + 2 /* may be PATH + COMSPEC */];
     276        for (; envc < environmentcount(); ++envc) {
     277            QString item = environmentat(envc);
    308278            envv[envc] = qstrdup(item.toLocal8Bit().constData());
    309279            if (!seenPATH)