531
546
#endif /* _PR_SHARE_CLONES */
550
_MD_CreateUnixProcessDetached(
554
const PRProcessAttr *attr)
559
RTENV newEnv = RTENV_DEFAULT;
561
/* this code doesn't support all attributes */
562
PR_ASSERT(!attr || !attr->currentDirectory);
563
/* no custom environment, please */
566
childEnv = RTENV_DEFAULT;
567
if (attr && attr->fdInheritBuffer) {
568
vrc = RTEnvClone(&newEnv, childEnv);
571
vrc = RTEnvPutEx(newEnv, attr->fdInheritBuffer);
574
RTEnvDestroy(newEnv);
580
PRTHANDLE pStdIn = NULL, pStdOut = NULL, pStdErr = NULL;
581
RTHANDLE hStdIn, hStdOut, hStdErr;
582
if (attr && attr->stdinFd)
584
hStdIn.enmType = RTHANDLETYPE_FILE;
585
RTFileFromNative(&hStdIn.u.hFile, attr->stdinFd->secret->md.osfd);
588
if (attr && attr->stdoutFd)
590
hStdOut.enmType = RTHANDLETYPE_FILE;
591
RTFileFromNative(&hStdOut.u.hFile, attr->stdoutFd->secret->md.osfd);
594
if (attr && attr->stderrFd)
596
hStdErr.enmType = RTHANDLETYPE_FILE;
597
RTFileFromNative(&hStdErr.u.hFile, attr->stderrFd->secret->md.osfd);
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);
612
} /* _MD_CreateUnixProcessDetached */
534
616
* The pid table is a hashtable.
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);
678
761
* make sure we wait only for child of our group
679
762
* to ensure we do not interfere with RT
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);
683
768
pid = waitpid((pid_t) -1, &status, 0);
776
861
* make sure we wait only for child of our group
777
862
* to ensure we do not interfere with RT
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);
781
868
pid = waitpid((pid_t) -1, &status, WNOHANG);