I have some existing code using System.Diagnostics.Process.Start to start a child process. It also uses ProcessStartInfo.RedirectStandardOutput to capture the output of this process. It works very well.
I also need to attach it to the object. I have a code that does this too, and it works fine provided that the process is not attached to the task yet.
Unfortunately, this is not always the case, so I need to create a process with the flag CREATE_BREAKAWAY_FROM_JOB . This is where I am stuck.
As I see, there are two possible ways from here:
- Somehow convincing
Process.Start to pass this extra small flag. - Cancel the
Process class, go back to raw CreateProcess and (somehow) repeat the output redirection.
I am not sure how to do this, or if there is some kind of medium soil that can also work. Has anyone else come across this before and have some ideas / code?
source share