VirtualBox

Changeset 4475 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Sep 1, 2007 1:21:19 AM (17 years ago)
Author:
vboxsync
Message:

Some adjustments to RTEnv and RTProcCreate. Should work on darwin now.

Location:
trunk/src/VBox/Runtime/r3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/env-posix.cpp

    r4071 r4475  
    2323#include <iprt/string.h>
    2424#include <iprt/alloca.h>
     25#include <iprt/assert.h>
    2526
    2627#include <stdlib.h>
     
    7677}
    7778
     79
     80RTDECL(int) RTEnvUnset(const char *pszVar)
     81{
     82    AssertReturn(!strchr(pszVar, '='), VERR_INVALID_PARAMETER);
     83
     84    /* Check that it exists first.  */
     85    if (!RTEnvExist(pszVar))
     86        return VINF_ENV_VAR_NOT_FOUND;
     87
     88    /* Ok, try remove it. */
     89    if (!putenv((char *)pszVar))
     90        return VINF_SUCCESS;
     91    return RTErrConvertFromErrno(errno);
     92}
     93
  • trunk/src/VBox/Runtime/r3/posix/process-posix.cpp

    r4071 r4475  
    4242#include <iprt/assert.h>
    4343#include <iprt/err.h>
     44#include <iprt/env.h>
    4445#include "internal/process.h"
    4546
    4647
    4748
    48 RTR3DECL(int)   RTProcCreate(const char *pszExec, const char * const *papszArgs, const char * const *papszEnv, unsigned fFlags, PRTPROCESS pProcess)
     49RTR3DECL(int)   RTProcCreate(const char *pszExec, const char * const *papszArgs, RTENV Env, unsigned fFlags, PRTPROCESS pProcess)
    4950{
    5051    /*
    5152     * Validate input.
    5253     */
    53     if (!pszExec || !*pszExec)
    54     {
    55         AssertMsgFailed(("no exec\n"));
    56         return VERR_INVALID_PARAMETER;
    57     }
    58     if (fFlags)
    59     {
    60         AssertMsgFailed(("invalid flags!\n"));
    61         return VERR_INVALID_PARAMETER;
    62     }
     54    AssertPtrReturn(pszExec, VERR_INVALID_POINTER);
     55    AssertReturn(*pszExec, VERR_INVALID_PARAMETER);
     56    AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
     57    AssertReturn(Env != NIL_RTENV, VERR_INVALID_PARAMETER);
     58    const char * const *papszEnv = RTEnvGetExecEnvP(Env);
     59    AssertPtrReturn(papszEnv, VERR_INVALID_HANDLE);
    6360    /* later: path searching. */
    6461
     
    10097    /** @todo check if it requires any of those two attributes, don't remember atm. */
    10198    int rc = posix_spawn(&pid, pszExec, NULL, NULL, (char * const *)papszArgs,
    102                          papszEnv ? (char * const *)papszEnv : environ);
     99                         (char * const *)papszEnv);
    103100    if (!rc)
    104101    {
     
    114111    {
    115112        int rc;
    116         if (papszEnv)
    117             rc = execve(pszExec, (char * const *)papszArgs, (char * const *)papszEnv);
    118         else
    119             rc = execv(pszExec, (char * const *)papszArgs);
     113        rc = execve(pszExec, (char * const *)papszArgs, (char * const *)papszEnv);
    120114        AssertReleaseMsgFailed(("execve returns %d errno=%d\n", rc, errno));
    121115        exit(127);
  • trunk/src/VBox/Runtime/r3/win32/process-win32.cpp

    r4071 r4475  
    2929#include <iprt/assert.h>
    3030#include <iprt/err.h>
     31#include <iprt/env.h>
    3132
    3233
     
    6970/** @todo r=michael This function currently does not work correctly if the arguments
    7071                    contain spaces. */
    71 RTR3DECL(int)   RTProcCreate(const char *pszExec, const char * const *papszArgs, const char * const *papszEnv, unsigned fFlags, PRTPROCESS pProcess)
     72RTR3DECL(int)   RTProcCreate(const char *pszExec, const char * const *papszArgs, RTENV Env, unsigned fFlags, PRTPROCESS pProcess)
    7273{
    7374    /*
    7475     * Validate input.
    7576     */
    76     if (!pszExec || !*pszExec)
    77     {
    78         AssertMsgFailed(("no exec\n"));
    79         return VERR_INVALID_PARAMETER;
    80     }
    81     if (fFlags)
    82     {
    83         AssertMsgFailed(("invalid flags!\n"));
    84         return VERR_INVALID_PARAMETER;
    85     }
     77    AssertPtrReturn(pszExec, VERR_INVALID_POINTER);
     78    AssertReturn(*pszExec, VERR_INVALID_PARAMETER);
     79    AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
     80    AssertReturn(Env != NIL_RTENV, VERR_INVALID_PARAMETER);
     81    const char * const *papszEnv = RTEnvGetExecEnvP(Env);
     82    AssertPtrReturn(papszEnv, VERR_INVALID_HANDLE);
    8683    /* later: path searching. */
    87 
     84   
    8885    /*
    8986     * Spawn the child.
Note: See TracChangeset for help on using the changeset viewer.

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