Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDick Porter <dick@acm.org>2006-03-03 18:21:38 +0300
committerDick Porter <dick@acm.org>2006-03-03 18:21:38 +0300
commitd2699334665d3bbe17b0e9bc964810e92abd7498 (patch)
tree853feb90929c648b81663a16845e673555c0ad34 /mcs/class/System/System.Diagnostics/Process.cs
parent0e0aef8df8d4e0ea6396792aeb58c4888305f04c (diff)
2006-03-03 Dick Porter <dick@ximian.com>
* Process.cs: Close redirected pipes on errors. Fixes bug 77514. svn path=/trunk/mcs/; revision=57540
Diffstat (limited to 'mcs/class/System/System.Diagnostics/Process.cs')
-rw-r--r--mcs/class/System/System.Diagnostics/Process.cs30
1 files changed, 24 insertions, 6 deletions
diff --git a/mcs/class/System/System.Diagnostics/Process.cs b/mcs/class/System/System.Diagnostics/Process.cs
index 4f8f52e156a..4fa0839f56a 100644
--- a/mcs/class/System/System.Diagnostics/Process.cs
+++ b/mcs/class/System/System.Diagnostics/Process.cs
@@ -771,6 +771,7 @@ namespace System.Diagnostics {
IntPtr stdout_rd, stdout_wr;
IntPtr stderr_rd, stderr_wr;
bool ret;
+ MonoIOError error;
if (startInfo.HaveEnvVars) {
string [] strs = new string [startInfo.EnvironmentVariables.Count];
@@ -801,6 +802,11 @@ namespace System.Diagnostics {
ret = MonoIO.CreatePipe (out stdout_rd,
out stdout_wr);
if (ret == false) {
+ if (startInfo.RedirectStandardInput == true) {
+ MonoIO.Close (stdin_rd, out error);
+ MonoIO.Close (stdin_wr, out error);
+ }
+
throw new IOException ("Error creating standard output pipe");
}
} else {
@@ -812,6 +818,15 @@ namespace System.Diagnostics {
ret = MonoIO.CreatePipe (out stderr_rd,
out stderr_wr);
if (ret == false) {
+ if (startInfo.RedirectStandardInput == true) {
+ MonoIO.Close (stdin_rd, out error);
+ MonoIO.Close (stdin_wr, out error);
+ }
+ if (startInfo.RedirectStandardOutput == true) {
+ MonoIO.Close (stdout_rd, out error);
+ MonoIO.Close (stdout_wr, out error);
+ }
+
throw new IOException ("Error creating standard error pipe");
}
} else {
@@ -822,18 +837,21 @@ namespace System.Diagnostics {
ret = CreateProcess_internal (startInfo,
stdin_rd, stdout_wr, stderr_wr,
ref proc_info);
-
- MonoIOError error;
-
if (!ret) {
- if (startInfo.RedirectStandardInput == true)
+ if (startInfo.RedirectStandardInput == true) {
MonoIO.Close (stdin_rd, out error);
+ MonoIO.Close (stdin_wr, out error);
+ }
- if (startInfo.RedirectStandardOutput == true)
+ if (startInfo.RedirectStandardOutput == true) {
+ MonoIO.Close (stdout_rd, out error);
MonoIO.Close (stdout_wr, out error);
+ }
- if (startInfo.RedirectStandardError == true)
+ if (startInfo.RedirectStandardError == true) {
+ MonoIO.Close (stderr_rd, out error);
MonoIO.Close (stderr_wr, out error);
+ }
throw new Win32Exception (-proc_info.pid);
}