Assume the following code:
let sw = new StreamWriter("out.txt", false)
sw.AutoFlush <- true
let proc = new Process()
proc.StartInfo.FileName <- path
proc.StartInfo.RedirectStandardOutput <- true
proc.StartInfo.UseShellExecute <- false
proc.OutputDataReceived.Add(fun b -> sw.WriteLine b.Data )
proc.Start() |> ignore
proc.BeginOutputReadLine()
I create a process and exit the main application. The process is still running (as it should) but it stops redirecting the standard output. Is there any way how to continue writing the standard output to the file even after the main application exits?
PS: I have to exit the main application and cannot wait for the process to finish
PPS: I would like to do a similar thing for the standard error output