Changeset 600 for trunk/src


Ignore:
Timestamp:
Feb 24, 2010, 10:26:07 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

corelib: Fixed QProcess::startDetached() which would not work in 'highmem' mode (which is on by default). Closes #130.

Location:
trunk/src/corelib/io
Files:
2 edited

Legend:

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

    r561 r600  
    21322132    The started process will run as a regular standalone process.
    21332133
     2134    \bold{OS/2:} The started process will run in its own session which is
     2135    completely independent from the session of the starting application and
     2136    will continue execution after the starting application terminates.
     2137
    21342138    The process will be started in the directory \a workingDirectory.
    21352139
    21362140    If the function is successful then *\a pid is set to the process
    21372141    identifier of the started process.
     2142
     2143    Note that on OS/2, the PID of the started process is unknown and the value
     2144    returned in \a pid is always 0.
    21382145*/
    21392146bool QProcess::startDetached(const QString &program,
  • trunk/src/corelib/io/qprocess_os2.cpp

    r583 r600  
    5353#include <qthread.h>
    5454
     55#if defined(__INNOTEK_LIBC__)
     56#include <emx/umalloc.h> // for _lmalloc()
     57#endif
     58
    5559/*
    5660    Returns a human readable representation of the first \a len
     
    941945                    // @todo use P_SESSION once it's implemented in kLIBC!
    942946                    // @todo check if FS VIO apps need a proxy
    943                     programReal = getenv("COMSPEC"); // returns static!
     947                    programReal = ::getenv("COMSPEC"); // returns static!
    944948                    if (programReal == 0)
    945949                        programReal = "cmd.exe";
     
    984988                args.prepend(programReal);
    985989                args.prepend("/C \"");
    986                 programReal = getenv("COMSPEC"); // returns static!
     990                programReal = ::getenv("COMSPEC"); // returns static!
    987991                if (programReal == 0)
    988992                    programReal = "cmd.exe";
     
    993997                for (char **e = envv; *e; ++e)
    994998                    env += *e + '\0';
     999
     1000#if defined(__INNOTEK_LIBC__)
     1001            // make sure we store arguments in the low memory for
     1002            // DosStartSession() as it cannot work with high memory
     1003            PSZ pgmNameLow = (PSZ)::_lmalloc(::strlen(programReal) + 1);
     1004            ::strcpy(pgmNameLow, programReal);
     1005            PSZ argsLow = (PSZ)::_lmalloc(args.size());
     1006            ::memcpy(argsLow, args, args.size());
     1007            PSZ envLow = 0;
     1008            if (!env.isEmpty()) {
     1009                envLow = (PSZ)::_lmalloc(env.size());
     1010                ::memcpy(envLow, env, env.size());
     1011            }
     1012#else
     1013            PSZ pgmNameLow = (PSZ)programReal;
     1014            PSZ argsLow = args.data();
     1015            PSZ envLow = env.isEmpty() ? 0 : env.data();
     1016#endif
    9951017
    9961018            STARTDATA data;
     
    10001022            data.TraceOpt = SSF_TRACEOPT_NONE;
    10011023            data.PgmTitle = 0;
    1002             data.PgmName = (PSZ)programReal;
    1003             data.PgmInputs = args.data();
     1024            data.PgmName = pgmNameLow;
     1025            data.PgmInputs = argsLow;
    10041026            data.TermQ = 0;
    1005             data.Environment = env.isEmpty() ? 0 : env.data();
     1027            data.Environment = envLow;
    10061028            data.InheritOpt = SSF_INHERTOPT_PARENT;
    10071029            data.SessionType = SSF_TYPE_DEFAULT;
     
    10141036            data.ObjectBuffLen = 0;
    10151037
    1016             ULONG ulSid, ulPid;
    1017             if (DosStartSession(&data, &ulSid, &ulPid) == NO_ERROR)
    1018                 pid = ulPid;
     1038            ULONG ulSid, ulPidDummy;
     1039            arc = DosStartSession(&data, &ulSid, &ulPidDummy);
     1040#if defined(QPROCESS_DEBUG)
     1041            qDebug("qt_startProcess: DosStartSession() returned %ld", arc);
     1042#endif
     1043            // Note: for SSF_RELATED_INDEPENDENT, PID of the started process is
     1044            // unknown, return 0 to indicate this
     1045            if (arc == NO_ERROR)
     1046                pid = 0;
     1047            else
     1048                pid = -1;
     1049
     1050#if defined(__INNOTEK_LIBC__)
     1051            if (envLow)
     1052                ::free(envLow);
     1053            ::free(argsLow);
     1054            ::free(pgmNameLow);
     1055#endif
    10191056        } else {
    10201057            pid = spawnve(mode, programReal, const_cast<char * const *>(argvReal), envv);
Note: See TracChangeset for help on using the changeset viewer.