[System] Dispose all streams in Process::Close if they were not exposed to the user...
authorRodrigo Kumpera <kumpera@gmail.com>
Wed, 5 Oct 2016 21:51:01 +0000 (14:51 -0700)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 5 Oct 2016 21:51:01 +0000 (14:51 -0700)
commit67d44f8ebfd7424846a08d8e00cc0091899f2ddd
tree1553b0b898a1023c18a0ee561bcd7fbeb05c6686
parentd60084ccdc65b56b1022d62035c07c0dc57faaa4
[System] Dispose all streams in Process::Close if they were not exposed to the user. Fixes a RS import regression.

RS takes the stance that redirected streams should not be closed by the Process class because they might
be referenced from the outside.

That would be ok if it was true. If you use Process::BeginOutputReadLine, the output stream becomes inaccessible
with no way to dispose them by any mean but GC.Collect. You get an exception when accessing Process::StandardOutput
once async reading starts.

This change addresses the case where the streams are not accessible. This is tracked by the *StreamReadMode variables
that are set on stream getters or Begin*ReadLine.
mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs