private static int RunProcess(DirectoryServiceContract.Imp !ds, string[] args, PipeMultiplexer !outputMux) { Process child = Binder.CreateProcess(ds, args, outputMux); if (child != null) { child.Start(); child.Join(); return(0); } return(-1); }
//[ShellCommand("StartProcess", "tests lib routine to start process with Manifest")] internal static int AppMain(Parameters !config) { DirectoryServiceContract.Imp ds = null; if (config.nsRef != null) { ds = config.nsRef.Acquire(); } if (ds == null) { throw new Exception("Unable to acquire handle to the Directory Service root"); } ds.RecvSuccess(); // Make ourselves a new output pipe UnicodePipeContract.Exp !newOutputExp; UnicodePipeContract.Imp !newOutputImp; UnicodePipeContract.NewChannel(out newOutputImp, out newOutputExp); // Retrieve our real stdOut and start using the one we just created // instead UnicodePipeContract.Imp stdOut = ConsoleOutput.Swap(newOutputImp); if (stdOut == null) { Console.WriteLine("runtests expects a STDOUT pipe"); delete newOutputExp; delete ds; return(1); } // Use a mux to splice our own output together with the child // processes we will run. PipeMultiplexer !outputMux = PipeMultiplexer.Start(stdOut, newOutputExp); string[] args = config.Args; if (args != null && args[0] != null) { RunProcess(ds, args, outputMux); } outputMux.Dispose(); delete ds; return(0); }