I have some existing code making use of System.Diagnostics.Process.Start
to start a child process. It also uses ProcessStartInfo.RedirectStandardOutput
to capture the output stream of that process. This much is working fine.
I also need to attach it to a job object. I have code which does this as well, and it works fine provided that the process is not already attached to a job.
Unfortunately, that isn't always the case, so I need to create the process with the CREATE_BREAKAWAY_FROM_JOB
flag. This is where I'm stuck.
As I see it, there are two possible ways forward from here:
Process.Start
to pass that one extra little flag.Process
class, fall back to raw CreateProcess
, and (somehow) redo the output redirection.I'm not really sure how to do either of these, or if there's some middle ground which might also work. Has anyone else run into this before and have some ideas/code?
For the moment, I've gone with option #2. I think I've worked out how to do the output capturing, though I haven't tested it extensively yet.
Still interested in alternative ideas, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With