~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/libs/xpcom18a4/nsprpub/pr/src/md/unix/uxproces.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
static PRLock *_pr_vms_fork_lock = NULL;
64
64
#endif
65
65
 
 
66
#ifdef VBOX
 
67
#include <iprt/err.h>
 
68
#include <iprt/env.h>
 
69
#include <iprt/file.h>
 
70
#include <iprt/process.h>
 
71
#endif
 
72
 
66
73
/*
67
74
 **********************************************************************
68
75
 *
178
185
    int flags;
179
186
#ifdef VMS
180
187
    char VMScurdir[FILENAME_MAX+1] = { '\0' } ;
181
 
#endif  
 
188
#endif
182
189
 
183
190
    process = PR_NEW(PRProcess);
184
191
    if (!process) {
460
467
    char *const *envp,
461
468
    const PRProcessAttr *attr)
462
469
{
 
470
#ifdef VBOX
 
471
    /* 2010-10-11 Block this for good. */
 
472
    return NULL;
 
473
#endif
463
474
    struct pr_CreateProcOp *op;
464
475
    PRProcess *proc;
465
476
    int rv;
522
533
    char *const *envp,
523
534
    const PRProcessAttr *attr)
524
535
{
 
536
#ifdef VBOX
 
537
    /* 2010-10-11 Block this for good. */
 
538
    return NULL;
 
539
#endif
525
540
    if (PR_CallOnce(&pr_wp.once, _MD_InitProcesses) == PR_FAILURE) {
526
541
        return NULL;
527
542
    }
530
545
 
531
546
#endif  /* _PR_SHARE_CLONES */
532
547
 
 
548
#ifdef VBOX
 
549
PRStatus
 
550
_MD_CreateUnixProcessDetached(
 
551
    const char *path,
 
552
    char *const *argv,
 
553
    char *const *envp,
 
554
    const PRProcessAttr *attr)
 
555
{
 
556
    int vrc;
 
557
    int nEnv, idx;
 
558
    RTENV childEnv;
 
559
    RTENV newEnv = RTENV_DEFAULT;
 
560
 
 
561
    /* this code doesn't support all attributes */
 
562
    PR_ASSERT(!attr || !attr->currentDirectory);
 
563
    /* no custom environment, please */
 
564
    PR_ASSERT(!envp);
 
565
 
 
566
    childEnv = RTENV_DEFAULT;
 
567
    if (attr && attr->fdInheritBuffer) {
 
568
        vrc = RTEnvClone(&newEnv, childEnv);
 
569
        if (RT_FAILURE(vrc))
 
570
            return PR_FAILURE;
 
571
        vrc = RTEnvPutEx(newEnv, attr->fdInheritBuffer);
 
572
        if (RT_FAILURE(vrc))
 
573
        {
 
574
            RTEnvDestroy(newEnv);
 
575
            return PR_FAILURE;
 
576
        }
 
577
        childEnv = newEnv;
 
578
    }
 
579
 
 
580
    PRTHANDLE pStdIn = NULL, pStdOut = NULL, pStdErr = NULL;
 
581
    RTHANDLE hStdIn, hStdOut, hStdErr;
 
582
    if (attr && attr->stdinFd)
 
583
    {
 
584
        hStdIn.enmType = RTHANDLETYPE_FILE;
 
585
        RTFileFromNative(&hStdIn.u.hFile, attr->stdinFd->secret->md.osfd);
 
586
        pStdIn = &hStdIn;
 
587
    }
 
588
    if (attr && attr->stdoutFd)
 
589
    {
 
590
        hStdOut.enmType = RTHANDLETYPE_FILE;
 
591
        RTFileFromNative(&hStdOut.u.hFile, attr->stdoutFd->secret->md.osfd);
 
592
        pStdOut = &hStdOut;
 
593
    }
 
594
    if (attr && attr->stderrFd)
 
595
    {
 
596
        hStdErr.enmType = RTHANDLETYPE_FILE;
 
597
        RTFileFromNative(&hStdErr.u.hFile, attr->stderrFd->secret->md.osfd);
 
598
        pStdErr = &hStdErr;
 
599
    }
 
600
 
 
601
    vrc = RTProcCreateEx(path, (const char **)argv, childEnv,
 
602
                         RTPROC_FLAGS_DETACHED, pStdIn, pStdOut, pStdErr,
 
603
                         NULL /* pszAsUser */, NULL /* pszPassword */,
 
604
                         NULL /* phProcess */);
 
605
    if (newEnv != RTENV_DEFAULT) {
 
606
        RTEnvDestroy(newEnv);
 
607
    }
 
608
    if (RT_SUCCESS(vrc))
 
609
        return PR_SUCCESS;
 
610
    else
 
611
        return PR_FAILURE;
 
612
}  /* _MD_CreateUnixProcessDetached */
 
613
#endif
 
614
 
533
615
/*
534
616
 * The pid table is a hashtable.
535
617
 *
629
711
         * variable. Treat it like a detached process. The proper fix would be
630
712
         * to port the NSPR to use IPRT, as currently this races with getting
631
713
         * the exit code, but that's pretty harmless. */
632
 
        /** @todo fix this properly, by using IPRT for process management */
 
714
        /* Since 2010-10-11 this code cannot be reached as IPRT took over
 
715
         * what we need, and the rest is blocked. */
633
716
        if (_PR_PID_REAPED == pRec->state) {
634
717
            DeletePidTable(pRec);
635
718
            PR_DELETE(pRec);
678
761
                 * make sure we wait only for child of our group
679
762
                 * to ensure we do not interfere with RT
680
763
                 */
 
764
            /* Since 2010-10-11 this code cannot be reached as IPRT took over
 
765
             * what we need, and the rest is blocked. */
681
766
                pid = waitpid((pid_t) 0, &status, 0);
682
767
#else
683
768
                pid = waitpid((pid_t) -1, &status, 0);
687
772
            /*
688
773
             * waitpid() cannot return 0 because we did not invoke it
689
774
             * with the WNOHANG option.
690
 
             */ 
 
775
             */
691
776
            PR_ASSERT(0 != pid);
692
777
 
693
778
            /*
744
829
        }
745
830
        PR_Lock(pr_wp.ml);
746
831
#endif
747
 
            
 
832
 
748
833
        do {
749
834
            rv = read(pr_wp.pipefd[0], buf, sizeof(buf));
750
835
        } while (sizeof(buf) == rv || (-1 == rv && EINTR == errno));
776
861
                 * make sure we wait only for child of our group
777
862
                 * to ensure we do not interfere with RT
778
863
                 */
 
864
            /* Since 2010-10-11 this code cannot be reached as IPRT took over
 
865
             * what we need, and the rest is blocked. */
779
866
                pid = waitpid((pid_t) 0, &status, WNOHANG);
780
867
#else
781
868
                pid = waitpid((pid_t) -1, &status, WNOHANG);