I am creating a process from another process in C# as follows:
process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = "process.exe";
process.OutputDataReceived += ProcessOnOutputDataReceived;
Then in a separate thread I call:
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();
This allows me to have rudimentary IPC between the processes.
I am finding that this process appears to be inheriting an open file handle from the parent process. As a result, the parent process can no longer work with the file.
Is there a way to prevent this from happening? Or is there a way that I can force the child process to release the handle after it has been inherited?