Fix for concurrent child processes while using pipes for IPC.

This commit is contained in:
Matthew Bowra-Dean
2011-01-04 14:23:46 +13:00
parent c8a74ef05a
commit fb8812a7fd
5 changed files with 31 additions and 15 deletions

View File

@@ -46,9 +46,10 @@ namespace OpenRA.Utility
var arg = SplitArgs(args[0]);
bool piping = false;
if (args.Length > 1 && args[1] == "--pipe")
if (args.Length > 1 && SplitArgs(args[1]).Key == "--pipe")
{
piping = true;
string pipename = SplitArgs(args[1]).Value;
NamedPipeServerStream pipe;
var id = WindowsIdentity.GetCurrent();
var principal = new WindowsPrincipal(id);
@@ -56,10 +57,10 @@ namespace OpenRA.Utility
{
var ps = new PipeSecurity();
ps.AddAccessRule(new PipeAccessRule("EVERYONE", (PipeAccessRights)2032031, System.Security.AccessControl.AccessControlType.Allow));
pipe = new NamedPipeServerStream("OpenRA.Utility", PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.None, 1024, 1024, ps);
pipe = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.None, 1024, 1024, ps);
}
else
pipe = new NamedPipeServerStream("OpenRA.Utility", PipeDirection.Out);
pipe = new NamedPipeServerStream(pipename, PipeDirection.Out);
pipe.WaitForConnection();
Console.SetOut(new StreamWriter(pipe) { AutoFlush = true });