VirtualBox

Changeset 33044 in vbox for trunk/src


Ignore:
Timestamp:
Oct 11, 2010 4:30:54 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
66568
Message:

iprt/process: eliminate RTPROC_FLAGS_DAEMONIZE_DEPRECATED, rework starting a detached process on posix platforms and eliminate one useless fork(), avoid running

atexit functions in the temporary process

XPCOM: more detached process rework, block anything not going through IPRT, clos
e a few file descriptor inheritance leaks, and clean up the file descriptor pass
ing to VBoxXPCOMIPCD

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r32741 r33044  
    483483{
    484484    /* Get the path to the executable. */
    485     char path [RTPATH_MAX];
    486     RTPathAppPrivateArch (path, RTPATH_MAX);
    487     size_t sz = strlen (path);
    488     path [sz++] = RTPATH_DELIMITER;
    489     path [sz] = 0;
     485    char path[RTPATH_MAX];
     486    RTPathAppPrivateArch(path, RTPATH_MAX);
     487    size_t sz = strlen(path);
     488    path[sz++] = RTPATH_DELIMITER;
     489    path[sz] = 0;
    490490    char *cmd = path + sz;
    491491    sz = RTPATH_MAX - sz;
    492492
    493493    int rc = 0;
    494     RTPROCESS pid = NIL_RTPROCESS;
    495     RTENV env = RTENV_DEFAULT;
    496 
    497494    const char VirtualBox_exe[] = "VirtualBox" HOSTSUFF_EXE;
    498     Assert (sz >= sizeof (VirtualBox_exe));
    499     strcpy (cmd, VirtualBox_exe);
     495    Assert(sz >= sizeof(VirtualBox_exe));
     496    strcpy(cmd, VirtualBox_exe);
    500497    const char * args[] = {path, 0 };
    501 # ifdef RT_OS_WINDOWS
    502     rc = RTProcCreate (path, args, env, 0, &pid);
    503 # else
    504     rc = RTProcCreate (path, args, env, RTPROC_FLAGS_DAEMONIZE_DEPRECATED, &pid);
    505 # endif
    506     if (RT_FAILURE (rc))
     498    rc = RTProcCreate(path, args, RTENV_DEFAULT, RTPROC_FLAGS_DETACHED, NULL);
     499    if (RT_FAILURE(rc))
    507500        LogRel(("Systray: Failed to start new selector window! Path=%s, rc=%Rrc\n", path, rc));
    508501}
     
    515508{
    516509    int rc = 0;
    517     QString strTrayWinID = mVBox.GetExtraData (VBoxDefs::GUI_TrayIconWinID);
     510    QString strTrayWinID = mVBox.GetExtraData(VBoxDefs::GUI_TrayIconWinID);
    518511    if (false == strTrayWinID.isEmpty())
    519512    {
    520513        /* Check if current tray icon is alive by writing some bogus value. */
    521         mVBox.SetExtraData (VBoxDefs::GUI_TrayIconWinID, "0");
     514        mVBox.SetExtraData(VBoxDefs::GUI_TrayIconWinID, "0");
    522515        if (mVBox.isOk())
    523516        {
    524517            /* Current tray icon died - clean up. */
    525             mVBox.SetExtraData (VBoxDefs::GUI_TrayIconWinID, NULL);
     518            mVBox.SetExtraData(VBoxDefs::GUI_TrayIconWinID, NULL);
    526519            strTrayWinID.clear();
    527520        }
     
    535528    {
    536529        /* Get the path to the executable. */
    537         char path [RTPATH_MAX];
    538         RTPathAppPrivateArch (path, RTPATH_MAX);
    539         size_t sz = strlen (path);
    540         path [sz++] = RTPATH_DELIMITER;
    541         path [sz] = 0;
     530        char path[RTPATH_MAX];
     531        RTPathAppPrivateArch(path, RTPATH_MAX);
     532        size_t sz = strlen(path);
     533        path[sz++] = RTPATH_DELIMITER;
     534        path[sz] = 0;
    542535        char *cmd = path + sz;
    543536        sz = RTPATH_MAX - sz;
    544537
    545         RTPROCESS pid = NIL_RTPROCESS;
    546         RTENV env = RTENV_DEFAULT;
    547 
    548538        const char VirtualBox_exe[] = "VirtualBox" HOSTSUFF_EXE;
    549         Assert (sz >= sizeof (VirtualBox_exe));
    550         strcpy (cmd, VirtualBox_exe);
     539        Assert(sz >= sizeof(VirtualBox_exe));
     540        strcpy(cmd, VirtualBox_exe);
    551541        const char * args[] = {path, "-systray", 0 };
    552 # ifdef RT_OS_WINDOWS /** @todo drop this once the RTProcCreate bug has been fixed */
    553         rc = RTProcCreate (path, args, env, 0, &pid);
    554 # else
    555         rc = RTProcCreate (path, args, env, RTPROC_FLAGS_DAEMONIZE_DEPRECATED, &pid);
    556 # endif
    557 
    558         if (RT_FAILURE (rc))
     542        rc = RTProcCreate(path, args, RTENV_DEFAULT, RTPROC_FLAGS_DETACHED, NULL);
     543        if (RT_FAILURE(rc))
    559544        {
    560545            LogRel(("Systray: Failed to start systray window! Path=%s, rc=%Rrc\n", path, rc));
     
    566551    {
    567552        // Use this selector for displaying the tray icon
    568         mVBox.SetExtraData (VBoxDefs::GUI_TrayIconWinID,
    569                             QString ("%1").arg ((qulonglong) vboxGlobal().mainWindow()->winId()));
     553        mVBox.SetExtraData(VBoxDefs::GUI_TrayIconWinID,
     554                           QString("%1").arg((qulonglong)vboxGlobal().mainWindow()->winId()));
    570555
    571556        /* The first process which can grab this "mutex" will win ->
     
    49354920/**
    49364921 * Initialize a debugger config variable.
    4937  * 
     4922 *
    49384923 * @param   piDbgCfgVar         The debugger config variable to init.
    4939  * @param   pszEnvVar           The environment variable name relating to this 
     4924 * @param   pszEnvVar           The environment variable name relating to this
    49404925 *                              variable.
    49414926 * @param   pszExtraDataName    The extra data name relating to this variable.
     
    49644949    else if (strEnvValue.isNull() && strExtraValue.isNull())
    49654950        *piDbgCfgVar = fDefault ? VBOXGLOBAL_DBG_CFG_VAR_TRUE : VBOXGLOBAL_DBG_CFG_VAR_FALSE;
    4966     else 
     4951    else
    49674952    {
    49684953        QString *pStr = !strEnvValue.isEmpty() ? &strEnvValue : &strExtraValue;
     
    49804965                 || pStr->toLongLong() == 0)
    49814966            *piDbgCfgVar = VBOXGLOBAL_DBG_CFG_VAR_FALSE;
    4982         else 
     4967        else
    49834968        {
    49844969            LogFunc(("Ignoring unknown value '%s' for '%s'\n", pStr->toAscii().constData(), pStr == &strEnvValue ? pszEnvVar : pszExtraDataName));
     
    49884973}
    49894974
    4990 /** 
    4991  * Set a debugger config variable according according to start up argument. 
    4992  * 
    4993  * @param   piDbgCfgVar         The debugger config variable to set. 
    4994  * @param   fState              The value from the command line. 
    4995  */ 
     4975/**
     4976 * Set a debugger config variable according according to start up argument.
     4977 *
     4978 * @param   piDbgCfgVar         The debugger config variable to set.
     4979 * @param   fState              The value from the command line.
     4980 */
    49964981void VBoxGlobal::setDebuggerVar(int *piDbgCfgVar, bool fState)
    49974982{
    49984983    if (!(*piDbgCfgVar & VBOXGLOBAL_DBG_CFG_VAR_DONE))
    4999         *piDbgCfgVar = (fState ? VBOXGLOBAL_DBG_CFG_VAR_TRUE : VBOXGLOBAL_DBG_CFG_VAR_FALSE) 
     4984        *piDbgCfgVar = (fState ? VBOXGLOBAL_DBG_CFG_VAR_TRUE : VBOXGLOBAL_DBG_CFG_VAR_FALSE)
    50004985                     | VBOXGLOBAL_DBG_CFG_VAR_CMD_LINE;
    50014986}
    50024987
    50034988/**
    5004  * Checks the state of a debugger config variable, updating it with the machine 
    5005  * settings on the first invocation. 
    5006  * 
     4989 * Checks the state of a debugger config variable, updating it with the machine
     4990 * settings on the first invocation.
     4991 *
    50074992 * @returns true / false.
    50084993 * @param   piDbgCfgVar         The debugger config variable to consult.
  • trunk/src/VBox/Main/xpcom/server.cpp

    r31872 r33044  
    10721072            /* now we're ready, signal the parent process */
    10731073            write(daemon_pipe_wr, "READY", strlen("READY"));
     1074            /* close writing end of the pipe, its job is done */
     1075            close(daemon_pipe_wr);
    10741076        }
    10751077        else
     
    11501152        RTFileDelete(g_pszPidFile);
    11511153
    1152     /* close writing end of the pipe as well */
    1153     if (daemon_pipe_wr >= 0)
    1154         close(daemon_pipe_wr);
    1155 
    11561154    return 0;
    11571155}
  • trunk/src/VBox/Runtime/r3/posix/process-posix.cpp

    r33009 r33044  
    266266    AssertPtrReturn(pszExec, VERR_INVALID_POINTER);
    267267    AssertReturn(*pszExec, VERR_INVALID_PARAMETER);
    268     AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER);
     268    AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER);
    269269    AssertReturn(!(fFlags & RTPROC_FLAGS_DETACHED) || !phProcess, VERR_INVALID_PARAMETER);
    270270    AssertReturn(hEnv != NIL_RTENV, VERR_INVALID_PARAMETER);
     
    346346    }
    347347
    348     /*
    349      * Spawn the child.
     348    pid_t pid = -1;
     349
     350    /*
     351     * Take care of detaching the process.
    350352     *
    351353     * HACK ALERT! Put the process into a new process group with pgid = pid
    352354     * to make sure it differs from that of the parent process to ensure that
    353      * the IPRT waipit call doesn't race anyone (read XPCOM) doing group wide
    354      * waits.
    355      */
    356     pid_t pid = -1;
     355     * the IPRT waitpid call doesn't race anyone (read XPCOM) doing group wide
     356     * waits. setsid() includes the setpgid() functionality.
     357     * 2010-10-11 XPCOM no longer waits for anything, but it cannot hurt.
     358     */
     359#ifndef RT_OS_OS2
     360    if (fFlags & RTPROC_FLAGS_DETACHED)
     361    {
     362# ifdef RT_OS_SOLARIS
     363        int templateFd = rtSolarisContractPreFork();
     364        if (templateFd == -1)
     365            return VERR_OPEN_FAILED;
     366# endif /* RT_OS_SOLARIS */
     367        pid = fork();
     368        if (!pid)
     369        {
     370# ifdef RT_OS_SOLARIS
     371            rtSolarisContractPostForkChild(templateFd);
     372# endif /* RT_OS_SOLARIS */
     373            setsid(); /* see comment above */
     374
     375            pid = -1;
     376            /* Child falls through to the actual spawn code below. */
     377        }
     378        else
     379        {
     380#ifdef RT_OS_SOLARIS
     381            rtSolarisContractPostForkParent(templateFd, pid);
     382#endif /* RT_OS_SOLARIS */
     383            if (pid > 0)
     384            {
     385                /* Must wait for the temporary process to avoid a zombie. */
     386                int status;
     387                waitpid(pid, &status, 0);
     388                /* Assume that something wasn't found. No detailed info. */
     389                if (status)
     390                    return VERR_PROCESS_NOT_FOUND;
     391                if (phProcess)
     392                    *phProcess = 0;
     393                return VINF_SUCCESS;
     394            }
     395            return RTErrConvertFromErrno(errno);
     396        }
     397    }
     398#endif
     399
     400    /*
     401     * Spawn the child.
     402     *
     403     * Any spawn code MUST not execute any atexit functions if it is for a
     404     * detached process. It would lead to running the atexit functions which
     405     * make only sense for the parent. libORBit e.g. gets confused by multiple
     406     * execution. Remember, there was only a fork() so far, and until exec()
     407     * is successfully run there is nothing which would prevent doing anything
     408     * silly with the (duplicated) file descriptors.
     409     */
    357410#ifdef HAVE_POSIX_SPAWN
    358411    /** @todo OS/2: implement DETACHED (BACKGROUND stuff), see VbglR3Daemonize.  */
    359     /** @todo Try do the detach thing with posix spawn.  */
    360     if (   !(fFlags & (RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED))
    361         && uid == ~(uid_t)0
    362         && gid == ~(gid_t)0
    363         )
     412    if (   uid == ~(uid_t)0
     413        && gid == ~(gid_t)0)
    364414    {
    365415        /* Spawn attributes. */
     
    428478            if (!rc)
    429479            {
     480                /* For a detached process this happens in the temp process, so
     481                 * it's not worth doing anything as this process must exit. */
     482                if (fFlags & RTPROC_FLAGS_DETACHED)
     483                _Exit(0);
    430484                if (phProcess)
    431485                    *phProcess = pid;
     
    433487            }
    434488        }
     489        /* For a detached process this happens in the temp process, so
     490         * it's not worth doing anything as this process must exit. */
     491        if (fFlags & RTPROC_FLAGS_DETACHED)
     492            _Exit(124);
    435493    }
    436494    else
     
    448506            rtSolarisContractPostForkChild(templateFd);
    449507#endif /* RT_OS_SOLARIS */
    450             setpgid(0, 0); /* see comment above */
     508            if (!(fFlags & RTPROC_FLAGS_DETACHED))
     509                setpgid(0, 0); /* see comment above */
    451510
    452511            /*
     
    457516            {
    458517                if (setgid(gid))
    459                     exit(126);
     518                {
     519                    if (fFlags & RTPROC_FLAGS_DETACHED)
     520                        _Exit(126);
     521                    else
     522                        exit(126);
     523                }
    460524            }
    461525
     
    463527            {
    464528                if (setuid(uid))
    465                     exit(126);
     529                {
     530                    if (fFlags & RTPROC_FLAGS_DETACHED)
     531                        _Exit(126);
     532                    else
     533                        exit(126);
     534                }
    466535            }
    467536#endif
     
    479548                    int rc2 = dup2(fd, i);
    480549                    if (rc2 != i)
    481                         exit(125);
     550                    {
     551                        if (fFlags & RTPROC_FLAGS_DETACHED)
     552                            _Exit(125);
     553                        else
     554                            exit(125);
     555                    }
    482556                    for (int j = i + 1; j < 3; j++)
    483557                        if (aStdFds[j] == fd)
     
    492566
    493567            /*
    494              * Daemonize the process if requested.
    495              */
    496             if (fFlags & (RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED))
    497             {
    498                 rc = RTProcDaemonizeUsingFork(true /*fNoChDir*/,
    499                                               !(fFlags & RTPROC_FLAGS_DAEMONIZE_DEPRECATED) /*fNoClose*/,
    500                                               NULL /* pszPidFile */);
    501                 if (RT_FAILURE(rc))
    502                 {
    503                     /* parent */
    504                     AssertReleaseMsgFailed(("RTProcDaemonize returns %Rrc errno=%d\n", rc, errno));
    505                     exit(127);
    506                 }
    507                 /* daemonized child */
    508             }
    509 
    510             /*
    511568             * Finally, execute the requested program.
    512569             */
     
    520577                RTAssertMsg2Weak("execve returns %d errno=%d\n", rc, errno);
    521578            RTAssertReleasePanic();
    522             exit(127);
     579            if (fFlags & RTPROC_FLAGS_DETACHED)
     580                _Exit(127);
     581            else
     582                exit(127);
    523583        }
    524584#ifdef RT_OS_SOLARIS
     
    527587        if (pid > 0)
    528588        {
     589            /* For a detached process this happens in the temp process, so
     590             * it's not worth doing anything as this process must exit. */
     591            if (fFlags & RTPROC_FLAGS_DETACHED)
     592                _Exit(0);
    529593            if (phProcess)
    530594                *phProcess = pid;
    531             else if (fFlags & (RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED))
    532             {
    533                 /* If the process is detached straight away wait for the
    534                  * intermediate process to exit (it should do that quickly)
    535                  * if the caller didn't want to know the PID. If it wants the
    536                  * PID it's his job to wait for it or he gets a zombie. */
    537                 waitpid(pid, NULL, 0);
    538             }
    539595            return VINF_SUCCESS;
    540596        }
    541         rc = errno;
    542     }
    543 
     597        /* For a detached process this happens in the temp process, so
     598         * it's not worth doing anything as this process must exit. */
     599        if (fFlags & RTPROC_FLAGS_DETACHED)
     600            _Exit(124);
     601        return RTErrConvertFromErrno(errno);
     602    }
    544603
    545604    return VERR_NOT_IMPLEMENTED;
  • trunk/src/VBox/Runtime/r3/win/process-win.cpp

    r32657 r33044  
    941941    AssertPtrReturn(pszExec, VERR_INVALID_POINTER);
    942942    AssertReturn(*pszExec, VERR_INVALID_PARAMETER);
    943     AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER);
     943    AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER);
    944944    AssertReturn(!(fFlags & RTPROC_FLAGS_DETACHED) || !phProcess, VERR_INVALID_PARAMETER);
    945945    AssertReturn(hEnv != NIL_RTENV, VERR_INVALID_PARAMETER);
  • trunk/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp

    r30514 r33044  
    12161216  PRProcessAttr *attr = nsnull;
    12171217  nsresult rv = NS_ERROR_FAILURE;
     1218  PRFileDesc *devNull;
    12181219  char *const argv[] = { (char *const) path, nsnull };
    12191220  char c;
     
    12331234
    12341235  if (PR_ProcessAttrSetInheritableFD(attr, writable, IPC_STARTUP_PIPE_NAME) != PR_SUCCESS)
     1236  goto end;
     1237
     1238  devNull = PR_Open("/dev/null", PR_RDWR, 0);
     1239  if (!devNull)
    12351240    goto end;
     1241
     1242  PR_ProcessAttrSetStdioRedirect(attr, PR_StandardInput, devNull);
     1243  PR_ProcessAttrSetStdioRedirect(attr, PR_StandardOutput, devNull);
     1244  PR_ProcessAttrSetStdioRedirect(attr, PR_StandardError, devNull);
    12361245
    12371246  if (PR_CreateProcessDetached(path, argv, nsnull, attr) != PR_SUCCESS)
    12381247    goto end;
    12391248
     1249  // Close /dev/null
     1250  PR_Close(devNull);
    12401251  // close the child end of the pipe in order to get notification on unexpected
    12411252  // child termination instead of being infinitely blocked in PR_Read().
  • trunk/src/libs/xpcom18a4/ipc/ipcd/daemon/src/ipcdUnix.cpp

    r20282 r33044  
    5050#endif
    5151
     52#ifdef VBOX
     53# include <iprt/initterm.h>
     54#endif
     55
    5256#include "prio.h"
    5357#include "prerror.h"
     
    467471    PRFileDesc *listenFD = NULL;
    468472    PRNetAddr addr;
     473
     474#ifdef VBOX
     475    /* Set up the runtime without loading the support driver. */
     476    RTR3Init();
     477#endif
    469478
    470479    //
     
    537546        }
    538547        else {
     548#ifndef VBOX
    539549            // redirect all standard file descriptors to /dev/null for
    540550            // proper daemonizing
     
    545555            PR_Close(PR_STDERR);
    546556            PR_Open("/dev/null", O_WRONLY, 0);
     557#endif
    547558
    548559            IPC_NotifyParent();
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/uxproces.c

    r32971 r33044  
    467467    const PRProcessAttr *attr)
    468468{
     469#ifdef VBOX
     470    /* 2010-10-11 Block this for good. */
     471    return NULL;
     472#endif
    469473    struct pr_CreateProcOp *op;
    470474    PRProcess *proc;
     
    529533    const PRProcessAttr *attr)
    530534{
     535#ifdef VBOX
     536    /* 2010-10-11 Block this for good. */
     537    return NULL;
     538#endif
    531539    if (PR_CallOnce(&pr_wp.once, _MD_InitProcesses) == PR_FAILURE) {
    532540        return NULL;
     
    550558    RTENV newEnv = RTENV_DEFAULT;
    551559
    552     if (PR_CallOnce(&pr_wp.once, _MD_InitProcesses) == PR_FAILURE) {
    553             return PR_FAILURE;
    554     }
    555560    /* this code doesn't support all attributes */
    556561    PR_ASSERT(!attr || !attr->currentDirectory);
    557     PR_ASSERT(!attr || !attr->stdinFd);
    558     PR_ASSERT(!attr || !attr->stdoutFd);
    559     PR_ASSERT(!attr || !attr->stderrFd);
    560562    /* no custom environment, please */
    561563    PR_ASSERT(!envp);
     
    575577    }
    576578
    577     vrc = RTProcCreate(path, (const char **)argv, childEnv,
    578                        RTPROC_FLAGS_DETACHED, NULL);
     579    PRTHANDLE pStdIn = NULL, pStdOut = NULL, pStdErr = NULL;
     580    RTHANDLE hStdIn, hStdOut, hStdErr;
     581    if (attr && attr->stdinFd)
     582    {
     583        hStdIn.enmType = RTHANDLETYPE_FILE;
     584        RTFileFromNative(&hStdIn.u.hFile, attr->stdinFd->secret->md.osfd);
     585        pStdIn = &hStdIn;
     586    }
     587    if (attr && attr->stdoutFd)
     588    {
     589        hStdOut.enmType = RTHANDLETYPE_FILE;
     590        RTFileFromNative(&hStdOut.u.hFile, attr->stdoutFd->secret->md.osfd);
     591        pStdOut = &hStdOut;
     592    }
     593    if (attr && attr->stderrFd)
     594    {
     595        hStdErr.enmType = RTHANDLETYPE_FILE;
     596        RTFileFromNative(&hStdErr.u.hFile, attr->stderrFd->secret->md.osfd);
     597        pStdErr = &hStdErr;
     598    }
     599
     600    vrc = RTProcCreateEx(path, (const char **)argv, childEnv,
     601                         RTPROC_FLAGS_DETACHED, pStdIn, pStdOut, pStdErr,
     602                         NULL /* pszAsUser */, NULL /* pszPassword */,
     603                         NULL /* phProcess */);
    579604    if (newEnv != RTENV_DEFAULT) {
    580605        RTEnvDestroy(newEnv);
     
    686711         * to port the NSPR to use IPRT, as currently this races with getting
    687712         * the exit code, but that's pretty harmless. */
    688         /** @todo fix this properly, by using IPRT for process management */
     713        /* Since 2010-10-11 this code cannot be reached as IPRT took over
     714         * what we need, and the rest is blocked. */
    689715        if (_PR_PID_REAPED == pRec->state) {
    690716            DeletePidTable(pRec);
     
    735761                 * to ensure we do not interfere with RT
    736762                 */
     763            /* Since 2010-10-11 this code cannot be reached as IPRT took over
     764             * what we need, and the rest is blocked. */
    737765                pid = waitpid((pid_t) 0, &status, 0);
    738766#else
     
    833861                 * to ensure we do not interfere with RT
    834862                 */
     863            /* Since 2010-10-11 this code cannot be reached as IPRT took over
     864             * what we need, and the rest is blocked. */
    835865                pid = waitpid((pid_t) 0, &status, WNOHANG);
    836866#else
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptio.c

    r11780 r33044  
    336336         * For sendfile()
    337337         */
    338                 struct file_spec {             
     338                struct file_spec {
    339339                off_t offset;                       /* offset in file to send */
    340340                size_t nbytes;                      /* length of file data to send */
     
    353353    int nbytes_to_send;                     /* size of header and file */
    354354#endif  /* HPUX11 */
    355    
     355
    356356#ifdef SOLARIS
    357357    /*
     
    369369    size_t count;
    370370#endif  /* LINUX */
    371  
     371
    372372    PRIntervalTime timeout;                 /* client (relative) timeout */
    373373
     
    402402    LL_I2L(aMil, 1000000);
    403403    LL_DIV(elapsed, elapsed, aMil);
    404    
     404
    405405    if (NULL != msg) PR_fprintf(debug_out, "%s", msg);
    406406    PR_fprintf(
     
    444444        PRBool wait_for_remaining;
    445445    PRThread *self = PR_GetCurrentThread();
    446    
     446
    447447        PR_ASSERT(PR_INTERVAL_NO_WAIT != op->timeout);
    448448        PR_ASSERT(op->arg1.osfd < FD_SETSIZE);
     
    491491                                        if ((op->event & POLLOUT) && FD_ISSET(op->arg1.osfd, &wr))
    492492                                                revents |= POLLOUT;
    493                                                
     493
    494494                                        if (op->function(op, revents))
    495495                                                op->status = pt_continuation_done;
     
    548548                                        if ((op->event & POLLOUT) && FD_ISSET(op->arg1.osfd, &wr))
    549549                                                revents |= POLLOUT;
    550                                                
     550
    551551                                        if (op->function(op, revents))
    552552                                                op->status = pt_continuation_done;
     
    587587        PRBool wait_for_remaining;
    588588    PRThread *self = PR_GetCurrentThread();
    589    
     589
    590590        PR_ASSERT(PR_INTERVAL_NO_WAIT != op->timeout);
    591591#if defined (_PR_POLL_WITH_SELECT)
     
    612612
    613613                                rv = poll(&tmp_pfd, 1, msecs);
    614                                
     614
    615615                                if (self->state & PT_THREAD_ABORTED)
    616616                                {
     
    670670                                }
    671671                                rv = poll(&tmp_pfd, 1, msecs);
    672                                
     672
    673673                                if (self->state & PT_THREAD_ABORTED)
    674674                                {
     
    686686
    687687                                        if ((revents & POLLNVAL)  /* busted in all cases */
    688                                                 || ((events & POLLOUT) && (revents & POLLHUP))) 
     688                                                || ((events & POLLOUT) && (revents & POLLHUP)))
    689689                                                                                        /* write op & hup */
    690690                                        {
     
    777777        op->arg1.osfd, op->arg2.buffer, op->arg3.amount);
    778778    op->syserrno = errno;
    779     return ((-1 == op->result.code) && 
     779    return ((-1 == op->result.code) &&
    780780            (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno)) ?
    781781        PR_FALSE : PR_TRUE;
     
    801801#endif
    802802    op->syserrno = errno;
    803     return ((-1 == op->result.code) && 
     803    return ((-1 == op->result.code) &&
    804804            (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno)) ?
    805805        PR_FALSE : PR_TRUE;
     
    961961        op->arg4.flags, (struct sockaddr*)op->arg5.addr, &addr_len);
    962962    op->syserrno = errno;
    963     return ((-1 == op->result.code) && 
     963    return ((-1 == op->result.code) &&
    964964            (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno)) ?
    965965        PR_FALSE : PR_TRUE;
     
    10691069#endif  /* HPUX11 */
    10701070
    1071 #ifdef SOLARIS 
     1071#ifdef SOLARIS
    10721072static PRBool pt_solaris_sendfile_cont(pt_Continuation *op, PRInt16 revents)
    10731073{
     
    10891089    }
    10901090    PR_ASSERT(count <= op->nbytes_to_send);
    1091    
     1091
    10921092    op->result.code += count;
    10931093    if (count < op->nbytes_to_send) {
     
    11131113#endif  /* SOLARIS */
    11141114
    1115 #ifdef LINUX 
     1115#ifdef LINUX
    11161116static PRBool pt_linux_sendfile_cont(pt_Continuation *op, PRInt16 revents)
    11171117{
     
    11521152    PR_ASSERT(NULL != _pr_flock_cv);
    11531153    _pr_rename_lock = PR_NewLock();
    1154     PR_ASSERT(NULL != _pr_rename_lock); 
    1155 
    1156     _PR_InitFdCache();  /* do that */   
     1154    PR_ASSERT(NULL != _pr_rename_lock);
     1155
     1156    _PR_InitFdCache();  /* do that */
    11571157
    11581158    _pr_stdin = pt_SetMethods(0, PR_DESC_FILE, PR_FALSE, PR_TRUE);
     
    11891189    _PR_Putfd(_pr_stdout);
    11901190    _pr_stdout = NULL;
    1191     _PR_Putfd(_pr_stderr); 
     1191    _PR_Putfd(_pr_stderr);
    11921192    _pr_stderr = NULL;
    11931193
    11941194    _PR_CleanupFdCache();
    1195    
     1195
    11961196    if (_pr_flock_cv)
    11971197    {
     
    12171217
    12181218    if (!_pr_initialized) _PR_ImplicitInitialization();
    1219    
     1219
    12201220    switch (osfd)
    12211221    {
     
    21262126}
    21272127
    2128 /* 
     2128/*
    21292129 * pt_AIXDispatchSendFile
    21302130 */
     
    21502150 *
    21512151 *    Send file sfd->fd across socket sd. If specified, header and trailer
    2152  *    buffers are sent before and after the file, respectively. 
     2152 *    buffers are sent before and after the file, respectively.
    21532153 *
    21542154 *    PR_TRANSMITFILE_CLOSE_SOCKET flag - close socket after sending file
    2155  *   
     2155 *
    21562156 *    return number of bytes sent or -1 on error
    21572157 *
     
    21602160 */
    21612161
    2162 static PRInt32 pt_AIXSendFile(PRFileDesc *sd, PRSendFileData *sfd, 
     2162static PRInt32 pt_AIXSendFile(PRFileDesc *sd, PRSendFileData *sfd,
    21632163                PRTransmitFileFlags flags, PRIntervalTime timeout)
    21642164{
     
    22502250 *
    22512251 *    PR_TRANSMITFILE_CLOSE_SOCKET flag - close socket after sending file
    2252  *   
     2252 *
    22532253 *    return number of bytes sent or -1 on error
    22542254 *
     
    22572257 */
    22582258
    2259 static PRInt32 pt_HPUXSendFile(PRFileDesc *sd, PRSendFileData *sfd, 
     2259static PRInt32 pt_HPUXSendFile(PRFileDesc *sd, PRSendFileData *sfd,
    22602260                PRTransmitFileFlags flags, PRIntervalTime timeout)
    22612261{
     
    22722272            _PR_MD_MAP_FSTAT_ERROR(errno);
    22732273            return -1;
    2274         }               
     2274        }
    22752275        file_nbytes_to_send = statbuf.st_size - sfd->file_offset;
    22762276    } else {
     
    23632363#endif  /* HPUX11 */
    23642364
    2365 #ifdef SOLARIS 
     2365#ifdef SOLARIS
    23662366
    23672367/*
     
    23832383{
    23842384    struct stat statbuf;
    2385     size_t nbytes_to_send, file_nbytes_to_send; 
    2386     struct sendfilevec sfv_struct[3]; 
    2387     int sfvcnt = 0;     
     2385    size_t nbytes_to_send, file_nbytes_to_send;
     2386    struct sendfilevec sfv_struct[3];
     2387    int sfvcnt = 0;
    23882388    size_t xferred;
    23892389    PRInt32 count;
     
    23952395            _PR_MD_MAP_FSTAT_ERROR(errno);
    23962396            return -1;
    2397         }               
     2397        }
    23982398        file_nbytes_to_send = statbuf.st_size - sfd->file_offset;
    23992399    } else {
     
    24062406        sfv_struct[sfvcnt].sfv_fd = SFV_FD_SELF;
    24072407        sfv_struct[sfvcnt].sfv_flag = 0;
    2408         sfv_struct[sfvcnt].sfv_off = (off_t) sfd->header; 
     2408        sfv_struct[sfvcnt].sfv_off = (off_t) sfd->header;
    24092409        sfv_struct[sfvcnt].sfv_len = sfd->hlen;
    24102410        sfvcnt++;
     
    24222422        sfv_struct[sfvcnt].sfv_fd = SFV_FD_SELF;
    24232423        sfv_struct[sfvcnt].sfv_flag = 0;
    2424         sfv_struct[sfvcnt].sfv_off = (off_t) sfd->trailer; 
     2424        sfv_struct[sfvcnt].sfv_off = (off_t) sfd->trailer;
    24252425        sfv_struct[sfvcnt].sfv_len = sfd->tlen;
    24262426        sfvcnt++;
     
    24312431        goto done;
    24322432    }
    2433            
     2433
    24342434    /*
    24352435     * Strictly speaking, we may have sent some bytes when the
     
    24982498    void *handle;
    24992499    PRBool close_it = PR_FALSE;
    2500  
     2500
    25012501    /*
    25022502     * We do not want to unload libsendfile.so.  This handle is leaked
     
    25212521    PR_LOG(_pr_io_lm, PR_LOG_DEBUG,
    25222522        ("dlsym(sendfilev) returns %p", pt_solaris_sendfilev_fptr));
    2523    
     2523
    25242524    if (close_it) {
    25252525        dlclose(handle);
     
    25272527}
    25282528
    2529 /* 
     2529/*
    25302530 * pt_SolarisDispatchSendFile
    25312531 */
     
    25562556 *
    25572557 *    PR_TRANSMITFILE_CLOSE_SOCKET flag - close socket after sending file
    2558  *   
     2558 *
    25592559 *    return number of bytes sent or -1 on error
    25602560 *
     
    25672567{
    25682568    struct stat statbuf;
    2569     size_t file_nbytes_to_send; 
     2569    size_t file_nbytes_to_send;
    25702570    PRInt32 count = 0;
    25712571    ssize_t rv;
     
    25802580            _PR_MD_MAP_FSTAT_ERROR(errno);
    25812581            return -1;
    2582         }               
     2582        }
    25832583        file_nbytes_to_send = statbuf.st_size - sfd->file_offset;
    25842584    } else {
     
    30753075    pt_FileInfo,
    30763076    pt_FileInfo64,
    3077     (PRWritevFN)_PR_InvalidInt,       
    3078     (PRConnectFN)_PR_InvalidStatus,       
    3079     (PRAcceptFN)_PR_InvalidDesc,       
    3080     (PRBindFN)_PR_InvalidStatus,       
    3081     (PRListenFN)_PR_InvalidStatus,       
    3082     (PRShutdownFN)_PR_InvalidStatus,   
    3083     (PRRecvFN)_PR_InvalidInt,       
    3084     (PRSendFN)_PR_InvalidInt,       
    3085     (PRRecvfromFN)_PR_InvalidInt,   
    3086     (PRSendtoFN)_PR_InvalidInt,       
     3077    (PRWritevFN)_PR_InvalidInt,
     3078    (PRConnectFN)_PR_InvalidStatus,
     3079    (PRAcceptFN)_PR_InvalidDesc,
     3080    (PRBindFN)_PR_InvalidStatus,
     3081    (PRListenFN)_PR_InvalidStatus,
     3082    (PRShutdownFN)_PR_InvalidStatus,
     3083    (PRRecvFN)_PR_InvalidInt,
     3084    (PRSendFN)_PR_InvalidInt,
     3085    (PRRecvfromFN)_PR_InvalidInt,
     3086    (PRSendtoFN)_PR_InvalidInt,
    30873087    pt_Poll,
    3088     (PRAcceptreadFN)_PR_InvalidInt,   
    3089     (PRTransmitfileFN)_PR_InvalidInt, 
    3090     (PRGetsocknameFN)_PR_InvalidStatus,   
    3091     (PRGetpeernameFN)_PR_InvalidStatus,   
    3092     (PRReservedFN)_PR_InvalidInt,   
    3093     (PRReservedFN)_PR_InvalidInt,   
     3088    (PRAcceptreadFN)_PR_InvalidInt,
     3089    (PRTransmitfileFN)_PR_InvalidInt,
     3090    (PRGetsocknameFN)_PR_InvalidStatus,
     3091    (PRGetpeernameFN)_PR_InvalidStatus,
     3092    (PRReservedFN)_PR_InvalidInt,
     3093    (PRReservedFN)_PR_InvalidInt,
    30943094    (PRGetsocketoptionFN)_PR_InvalidStatus,
    30953095    (PRSetsocketoptionFN)_PR_InvalidStatus,
    3096     (PRSendfileFN)_PR_InvalidInt, 
    3097     (PRConnectcontinueFN)_PR_InvalidStatus, 
    3098     (PRReservedFN)_PR_InvalidInt, 
    3099     (PRReservedFN)_PR_InvalidInt, 
    3100     (PRReservedFN)_PR_InvalidInt, 
     3096    (PRSendfileFN)_PR_InvalidInt,
     3097    (PRConnectcontinueFN)_PR_InvalidStatus,
     3098    (PRReservedFN)_PR_InvalidInt,
     3099    (PRReservedFN)_PR_InvalidInt,
     3100    (PRReservedFN)_PR_InvalidInt,
    31013101    (PRReservedFN)_PR_InvalidInt
    31023102};
     
    31143114    (PRFileInfoFN)_PR_InvalidStatus,
    31153115    (PRFileInfo64FN)_PR_InvalidStatus,
    3116     (PRWritevFN)_PR_InvalidInt,       
    3117     (PRConnectFN)_PR_InvalidStatus,       
    3118     (PRAcceptFN)_PR_InvalidDesc,       
    3119     (PRBindFN)_PR_InvalidStatus,       
    3120     (PRListenFN)_PR_InvalidStatus,       
    3121     (PRShutdownFN)_PR_InvalidStatus,   
    3122     (PRRecvFN)_PR_InvalidInt,       
    3123     (PRSendFN)_PR_InvalidInt,       
    3124     (PRRecvfromFN)_PR_InvalidInt,   
    3125     (PRSendtoFN)_PR_InvalidInt,       
     3116    (PRWritevFN)_PR_InvalidInt,
     3117    (PRConnectFN)_PR_InvalidStatus,
     3118    (PRAcceptFN)_PR_InvalidDesc,
     3119    (PRBindFN)_PR_InvalidStatus,
     3120    (PRListenFN)_PR_InvalidStatus,
     3121    (PRShutdownFN)_PR_InvalidStatus,
     3122    (PRRecvFN)_PR_InvalidInt,
     3123    (PRSendFN)_PR_InvalidInt,
     3124    (PRRecvfromFN)_PR_InvalidInt,
     3125    (PRSendtoFN)_PR_InvalidInt,
    31263126    pt_Poll,
    3127     (PRAcceptreadFN)_PR_InvalidInt,   
    3128     (PRTransmitfileFN)_PR_InvalidInt, 
    3129     (PRGetsocknameFN)_PR_InvalidStatus,   
    3130     (PRGetpeernameFN)_PR_InvalidStatus,   
    3131     (PRReservedFN)_PR_InvalidInt,   
    3132     (PRReservedFN)_PR_InvalidInt,   
     3127    (PRAcceptreadFN)_PR_InvalidInt,
     3128    (PRTransmitfileFN)_PR_InvalidInt,
     3129    (PRGetsocknameFN)_PR_InvalidStatus,
     3130    (PRGetpeernameFN)_PR_InvalidStatus,
     3131    (PRReservedFN)_PR_InvalidInt,
     3132    (PRReservedFN)_PR_InvalidInt,
    31333133    (PRGetsocketoptionFN)_PR_InvalidStatus,
    31343134    (PRSetsocketoptionFN)_PR_InvalidStatus,
    3135     (PRSendfileFN)_PR_InvalidInt, 
    3136     (PRConnectcontinueFN)_PR_InvalidStatus, 
    3137     (PRReservedFN)_PR_InvalidInt, 
    3138     (PRReservedFN)_PR_InvalidInt, 
    3139     (PRReservedFN)_PR_InvalidInt, 
     3135    (PRSendfileFN)_PR_InvalidInt,
     3136    (PRConnectcontinueFN)_PR_InvalidStatus,
     3137    (PRReservedFN)_PR_InvalidInt,
     3138    (PRReservedFN)_PR_InvalidInt,
     3139    (PRReservedFN)_PR_InvalidInt,
    31403140    (PRReservedFN)_PR_InvalidInt
    31413141};
     
    31723172    pt_GetSocketOption,
    31733173    pt_SetSocketOption,
    3174     pt_SendFile, 
     3174    pt_SendFile,
    31753175    pt_ConnectContinue,
    3176     (PRReservedFN)_PR_InvalidInt, 
    3177     (PRReservedFN)_PR_InvalidInt, 
    3178     (PRReservedFN)_PR_InvalidInt, 
     3176    (PRReservedFN)_PR_InvalidInt,
     3177    (PRReservedFN)_PR_InvalidInt,
     3178    (PRReservedFN)_PR_InvalidInt,
    31793179    (PRReservedFN)_PR_InvalidInt
    31803180};
     
    32113211    pt_GetSocketOption,
    32123212    pt_SetSocketOption,
    3213     (PRSendfileFN)_PR_InvalidInt, 
    3214     (PRConnectcontinueFN)_PR_InvalidStatus, 
    3215     (PRReservedFN)_PR_InvalidInt, 
    3216     (PRReservedFN)_PR_InvalidInt, 
    3217     (PRReservedFN)_PR_InvalidInt, 
     3213    (PRSendfileFN)_PR_InvalidInt,
     3214    (PRConnectcontinueFN)_PR_InvalidStatus,
     3215    (PRReservedFN)_PR_InvalidInt,
     3216    (PRReservedFN)_PR_InvalidInt,
     3217    (PRReservedFN)_PR_InvalidInt,
    32183218    (PRReservedFN)_PR_InvalidInt
    32193219};
     
    32313231    (PRFileInfoFN)_PR_InvalidStatus,
    32323232    (PRFileInfo64FN)_PR_InvalidStatus,
    3233     (PRWritevFN)_PR_InvalidInt,       
    3234     (PRConnectFN)_PR_InvalidStatus,       
    3235     (PRAcceptFN)_PR_InvalidDesc,       
    3236     (PRBindFN)_PR_InvalidStatus,       
    3237     (PRListenFN)_PR_InvalidStatus,       
    3238     (PRShutdownFN)_PR_InvalidStatus,   
    3239     (PRRecvFN)_PR_InvalidInt,       
    3240     (PRSendFN)_PR_InvalidInt,       
    3241     (PRRecvfromFN)_PR_InvalidInt,   
    3242     (PRSendtoFN)_PR_InvalidInt,       
     3233    (PRWritevFN)_PR_InvalidInt,
     3234    (PRConnectFN)_PR_InvalidStatus,
     3235    (PRAcceptFN)_PR_InvalidDesc,
     3236    (PRBindFN)_PR_InvalidStatus,
     3237    (PRListenFN)_PR_InvalidStatus,
     3238    (PRShutdownFN)_PR_InvalidStatus,
     3239    (PRRecvFN)_PR_InvalidInt,
     3240    (PRSendFN)_PR_InvalidInt,
     3241    (PRRecvfromFN)_PR_InvalidInt,
     3242    (PRSendtoFN)_PR_InvalidInt,
    32433243        pt_Poll,
    3244     (PRAcceptreadFN)_PR_InvalidInt,   
    3245     (PRTransmitfileFN)_PR_InvalidInt, 
    3246     (PRGetsocknameFN)_PR_InvalidStatus,   
    3247     (PRGetpeernameFN)_PR_InvalidStatus,   
    3248     (PRReservedFN)_PR_InvalidInt,   
    3249     (PRReservedFN)_PR_InvalidInt,   
     3244    (PRAcceptreadFN)_PR_InvalidInt,
     3245    (PRTransmitfileFN)_PR_InvalidInt,
     3246    (PRGetsocknameFN)_PR_InvalidStatus,
     3247    (PRGetpeernameFN)_PR_InvalidStatus,
     3248    (PRReservedFN)_PR_InvalidInt,
     3249    (PRReservedFN)_PR_InvalidInt,
    32503250    (PRGetsocketoptionFN)_PR_InvalidStatus,
    32513251    (PRSetsocketoptionFN)_PR_InvalidStatus,
    3252     (PRSendfileFN)_PR_InvalidInt, 
    3253     (PRConnectcontinueFN)_PR_InvalidStatus, 
    3254     (PRReservedFN)_PR_InvalidInt, 
    3255     (PRReservedFN)_PR_InvalidInt, 
    3256     (PRReservedFN)_PR_InvalidInt, 
     3252    (PRSendfileFN)_PR_InvalidInt,
     3253    (PRConnectcontinueFN)_PR_InvalidStatus,
     3254    (PRReservedFN)_PR_InvalidInt,
     3255    (PRReservedFN)_PR_InvalidInt,
     3256    (PRReservedFN)_PR_InvalidInt,
    32573257    (PRReservedFN)_PR_InvalidInt
    32583258};
     
    33063306{
    33073307    PRFileDesc *fd = _PR_Getfd();
    3308    
     3308
    33093309    if (fd == NULL) PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
    33103310    else
     
    33163316        {
    33173317            /* By default, a Unix fd is not closed on exec. */
    3318 #ifdef DEBUG
    33193318            PRIntn flags;
    33203319            flags = fcntl(osfd, F_GETFD, 0);
    3321             PR_ASSERT(0 == flags);
    3322 #endif
    3323             fd->secret->inheritable = _PR_TRI_TRUE;
     3320            fd->secret->inheritable = flags & FD_CLOEXEC ? _PR_TRI_FALSE : _PR_TRI_TRUE;
    33243321        }
    33253322        switch (type)
     
    33953392    fd->secret->inheritable = _PR_TRI_UNKNOWN;
    33963393    return fd;
    3397    
     3394
    33983395failed:
    33993396    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
     
    34643461#if defined(_PR_INET6_PROBE)
    34653462        if (PR_AF_INET6 == domain) {
    3466                 if (_pr_ipv6_is_present == PR_FALSE) 
     3463                if (_pr_ipv6_is_present == PR_FALSE)
    34673464                        domain = AF_INET;
    34683465                else
    34693466                        domain = AF_INET6;
    34703467        }
    3471 #elif defined(_PR_INET6) 
     3468#elif defined(_PR_INET6)
    34723469        if (PR_AF_INET6 == domain)
    34733470                domain = AF_INET6;
     
    34983495        if (fd != NULL) {
    34993496                /*
    3500                  * For platforms with no support for IPv6 
     3497                 * For platforms with no support for IPv6
    35013498                 * create layered socket for IPv4-mapped IPv6 addresses
    35023499                 */
     
    36143611    pt_MapError(_PR_MD_MAP_ACCESS_ERROR, errno);
    36153612    return PR_FAILURE;
    3616    
     3613
    36173614}  /* PR_Access */
    36183615
     
    36423639    ** a new file at the same time. And we have to hold that lock while we
    36433640    ** test to see if the file exists and do the rename. The other place
    3644     ** where the lock is held is in PR_Open() when possibly creating a 
     3641    ** where the lock is held is in PR_Open() when possibly creating a
    36453642    ** new file.
    36463643    */
     
    42504247                                                }
    42514248                                        }
    4252                 } else 
     4249                } else
    42534250                    _PR_MD_MAP_SELECT_ERROR(oserror);
    42544251            }
     
    43994396        return PR_FAILURE;
    44004397    }
     4398    fcntl(pipefd[0], F_SETFD, FD_CLOEXEC);
     4399    fcntl(pipefd[1], F_SETFD, FD_CLOEXEC);
    44014400    *readPipe = pt_SetMethods(pipefd[0], PR_DESC_PIPE, PR_FALSE, PR_FALSE);
    44024401    if (NULL == *readPipe)
     
    45624561    }
    45634562    PR_Unlock(_pr_flock_lock);
    4564  
     4563
    45654564    return status;
    45664565}  /* PR_LockFile */
     
    45804579    else fd->secret->lockCount += 1;
    45814580    PR_Unlock(_pr_flock_lock);
    4582  
     4581
    45834582    return status;
    45844583}  /* PR_TLockFile */
     
    46164615    struct rlimit rlim;
    46174616
    4618     if ( getrlimit(RLIMIT_NOFILE, &rlim) < 0) 
     4617    if ( getrlimit(RLIMIT_NOFILE, &rlim) < 0)
    46194618       return -1;
    46204619
     
    46444643        rlim.rlim_cur = table_size;
    46454644
    4646     if ( setrlimit(RLIMIT_NOFILE, &rlim) < 0) 
     4645    if ( setrlimit(RLIMIT_NOFILE, &rlim) < 0)
    46474646        return -1;
    46484647
     
    47714770    if (!pr_set)
    47724771        return 0;
    4773    
     4772
    47744773    FD_ZERO(set);
    47754774
     
    48134812
    48144813PR_IMPLEMENT(PRInt32) PR_Select(
    4815     PRInt32 unused, PR_fd_set *pr_rd, PR_fd_set *pr_wr, 
     4814    PRInt32 unused, PR_fd_set *pr_rd, PR_fd_set *pr_wr,
    48164815    PR_fd_set *pr_ex, PRIntervalTime timeout)
    48174816{
     
    48804879#endif /* defined(_PR_PTHREADS) */
    48814880
    4882 #ifdef MOZ_UNICODE 
     4881#ifdef MOZ_UNICODE
    48834882/* ================ UTF16 Interfaces ================================ */
    48844883PR_IMPLEMENT(PRFileDesc*) PR_OpenFileUTF16(
  • trunk/src/libs/xpcom18a4/xpcom/threads/plevent.c

    r30135 r33044  
    863863        return PR_FAILURE;
    864864    }
     865#ifdef VBOX
     866    fcntl(self->eventPipe[0], F_SETFD, FD_CLOEXEC);
     867    fcntl(self->eventPipe[1], F_SETFD, FD_CLOEXEC);
     868#endif
    865869
    866870    /* make the pipe nonblocking */
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