Changeset 218


Ignore:
Timestamp:
Oct 9, 2009, 11:34:45 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

tests/process: Added support for QProcess::startDetached() ("d" and "dcd" commands).

Location:
tests/process
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/process/process/process.cpp

    r209 r218  
    219219            }
    220220        }
     221        else if (cmd == "d" || cmd == "dcd")
     222        {
     223            QString workDir;
     224            if (cmd.endsWith("cd"))
     225            {
     226                QDir dir = QDir(QFileInfo(words[0]).path());
     227                workDir = dir.absolutePath();
     228            }
     229            else
     230            {
     231                workDir = QDir::currentPath();
     232            }
     233            mEditor->append(tr("> Working directory: '%1'").arg(workDir));
     234
     235            mEditor->append(tr("> Detaching: '%1'").arg(text));
     236            QStringList args = words;
     237            QString prg = args.takeFirst();
     238            qint64 pid;
     239            if (QProcess::startDetached(prg, args, workDir, &pid))
     240                mEditor->append(tr("> Detached successfully (pid '%1')").arg(pid));
     241            else
     242                mEditor->append(tr("> Detach failed"));
     243        }
    221244        else
    222245        {
  • tests/process/test/test.cpp

    r205 r218  
    2121#if 1
    2222
    23         sleep(3);
     23        //sleep(3);
    2424        int rc = write(fileno(stdout), "test-test", 9);
    2525        fprintf(stderr, "rc=%d %s\n", rc, strerror(errno));
    26         sleep(3);
     26        //sleep(3);
    2727        rc = write(fileno(stdout), "\nend", 4);
    2828        fprintf(stderr, "rc=%d %s\n", rc, strerror(errno));
    29         sleep(3);
     29        //sleep(3);
    3030        return 0;
    3131
Note: See TracChangeset for help on using the changeset viewer.