VirtualBox

Changeset 5058 in vbox for trunk/src/libs/xpcom18a4


Ignore:
Timestamp:
Sep 26, 2007 4:35:25 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
24871
Message:

XPCOM: Fixed _PR_DetachOS2Process() which now uses DosStartSession(SSF_TYPE_PM) instead of DosExecPgm(EXEC_BACKGROUND).

Location:
trunk/src/libs/xpcom18a4/nsprpub/pr/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/os2/os2misc.c

    r3368 r5058  
    6161
    6262
     63/* see assembleEnvBlock() below */
     64#define USE_DOSALLOCMEM
     65
     66
    6367/*
    6468 **************************************************************************
     
    204208    envBlockSize++;
    205209
     210    /* It seems that the Environment parameter of DosStartSession() and/or
     211     * DosExecPgm() wants a memory block that is completely within the 64K
     212     * memory object; otherwise we will get the environment truncated on the
     213     * 64K boundary in the child process. PR_MALLOC() cannot guarantee this,
     214     * so use DosAllocMem directly. */
     215#ifdef USE_DOSALLOCMEM
     216    DosAllocMem((PPVOID) envBlock, envBlockSize, PAG_COMMIT | PAG_READ | PAG_WRITE);
     217    p = *envBlock;
     218#else
    206219    p = *envBlock = PR_MALLOC(envBlockSize);
     220#endif
    207221    if (p == NULL) {
    208222        return -1;
     
    235249
    236250/*
    237  * On OS/2, you can only detach a new process -- you cannot make it detached
    238  * after it has been started. This is why _PR_CreateOS2ProcessEx() is
    239  * necessary. This function is called directly from PR_CreateProcessDetached().
    240  */
     251 * On OS/2, a process can be detached only when it is started -- you cannot
     252 * make it detached afterwards. This is why _PR_CreateOS2ProcessEx() is
     253 * necessary. This function is called directly from
     254 * PR_CreateProcessDetached().  */
    241255PRProcess * _PR_CreateOS2ProcessEx(
    242256    const char *path,
     
    281295     * it into the envp array, so envp cannot be NULL.
    282296     */
    283     if ((envp == NULL) && attr && attr->fdInheritBuffer) {
     297    if (envp == NULL && attr && attr->fdInheritBuffer) {
    284298        envp = environ;
    285299    }
     
    342356    }
    343357
     358    /* We don't want to use DosExecPgm for detached processes because
     359     * they won't have stdin/stderr/stdout by default which will hang up
     360     * the child process if it tries to write/read from there. Instead,
     361     * we will detach console processes by starting them using the PM session
     362     * (yes, it requires PM, but the whole XPCOM does so too).
     363     */
     364#if 0
    344365    if (detached) {
    345366        /* we don't care about parent/child process type matching,
     
    384405        }
    385406
    386         proc->md.pid = res.codeTerminate;
    387     }
    388     else {
     407        /* use 0 to indicate the detached process in the internal
     408         * process structure (I believe no process may have pid of 0) */
     409        proc->md.pid = 0 /* res.codeTerminate */;
     410    }
     411    else
     412#endif
     413    {
    389414        STARTDATA startData = {0};
    390415
     
    393418        }
    394419        else if (ulAppType & FAPPTYP_WINDOWCOMPAT) {
    395             startData.SessionType = SSF_TYPE_WINDOWABLEVIO;
     420            startData.SessionType = detached ? SSF_TYPE_PM
     421                                             : SSF_TYPE_WINDOWABLEVIO;
     422        }
     423        else if (ulAppType & FAPPTYP_NOTWINDOWCOMPAT) {
     424            startData.SessionType = detached ? SSF_TYPE_PM
     425                                             : SSF_TYPE_DEFAULT;
    396426        }
    397427        else {
     
    418448        startData.PgmName = pszEXEName;
    419449
     450        startData.Related = detached ? SSF_RELATED_INDEPENDENT : SSF_RELATED_CHILD;
     451
    420452        startData.Length = sizeof(startData);
    421         startData.Related = SSF_RELATED_INDEPENDENT;
    422453        startData.ObjectBuffer = pszObjectBuffer;
    423454        startData.ObjectBuffLen = CCHMAXPATH;
     
    431462        }
    432463
    433         proc->md.pid = pid;
     464        /* if Related is SSF_RELATED_INDEPENDENT, we don't get pid of the started
     465         * process and use 0 to indicate the detached process in the internal
     466         * process structure (I believe no process may have pid of 0).
     467         */
     468        proc->md.pid = detached ? 0 : pid;
    434469    }
    435470
     
    444479    }
    445480    if (envBlock) {
     481#ifdef USE_DOSALLOCMEM
     482        DosFreeMem(envBlock);
     483#else
    446484        PR_DELETE(envBlock);
     485#endif
    447486    }
    448487    return proc;
     
    459498    }
    460499    if (envBlock) {
     500#ifdef USE_DOSALLOCMEM
     501        DosFreeMem(envBlock);
     502#else
    461503        PR_DELETE(envBlock);
     504#endif
    462505    }
    463506    if (proc) {
     
    481524     * You can't 'detach' it later on.
    482525     */
    483     PR_DELETE(process);
    484     return PR_SUCCESS;
     526    if (process->md.pid == 0) {
     527        /* this is a detached process, just free memory */
     528        PR_DELETE(process);
     529        return PR_SUCCESS;
     530    }
     531    /* For a normal child process, we can't complete the request. Note that
     532     * terminating the parent process w/o calling PR_WaitProcess() on the
     533     * child will terminate the child as well (since it is not detached).
     534     */
     535    PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);
     536    return PR_FAILURE;
    485537}
    486538
     
    510562PRStatus _PR_KillOS2Process(PRProcess *process)
    511563{
    512    ULONG ulRetVal;
     564    ULONG ulRetVal;
    513565    if ((ulRetVal = DosKillProcess(DKP_PROCESS, process->md.pid)) == NO_ERROR) {
    514566        return PR_SUCCESS;
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinit.c

    r3368 r5058  
    740740    const PRProcessAttr *attr)
    741741{
    742 #ifdef XP_OS2
    743     PRProcess *process;
    744     process = _PR_CreateOS2ProcessEx(path, argv, envp, attr, PR_TRUE);
    745     if (NULL == process) {
    746         return PR_FAILURE;
    747     }
    748     return PR_SUCCESS;
    749 #else
    750742    PRProcess *process;
    751743    PRStatus rv;
    752744
     745#ifdef XP_OS2
     746    process = _PR_CreateOS2ProcessEx(path, argv, envp, attr, PR_TRUE);
     747#else
    753748    process = PR_CreateProcess(path, argv, envp, attr);
     749#endif
    754750    if (NULL == process) {
    755751        return PR_FAILURE;
     
    762758    }
    763759    return PR_SUCCESS;
    764 #endif
    765760}
    766761
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette