Skip to content

Commit

Permalink
[Process] Fix System.Diagnostics.ProcessTest.StandardInputWrite
Browse files Browse the repository at this point in the history
The child process would simpky execute ls, then exiting right away. Writing to its stdin would then crash with "EPIPE: An attempt is made to write to a pipe that is not open for reading by any process." as the child process exited.
  • Loading branch information
luhenry committed Apr 24, 2016
1 parent 8538842 commit e19a2e2
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions mcs/class/System/Test/System.Diagnostics/ProcessTest.cs
Expand Up @@ -881,6 +881,20 @@ ProcessStartInfo GetCrossPlatformStartInfo ()
} else
return new ProcessStartInfo ("help", "");
}

ProcessStartInfo GetEchoCrossPlatformStartInfo ()
{
if (RunningOnUnix) {
string path;
#if MONODROID
path = "/system/bin/cat";
#else
path = "/bin/cat";
#endif
return new ProcessStartInfo (path);
} else
return new ProcessStartInfo ("type");
}
#endif // MONO_FEATURE_PROCESS_START

[Test]
Expand Down Expand Up @@ -972,14 +986,25 @@ public void DisposeWithDisposedStreams ()
[NUnit.Framework.Category ("MobileNotWorking")]
public void StandardInputWrite ()
{
var psi = GetCrossPlatformStartInfo ();
var psi = GetEchoCrossPlatformStartInfo ();
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;

using (var p = Process.Start (psi)) {
for (int i = 0; i < 1024 * 9; ++i)
// drain stdout
p.OutputDataReceived += (s, e) => {};
p.BeginOutputReadLine ();

for (int i = 0; i < 1024 * 9; ++i) {
p.StandardInput.Write ('x');
if (i > 0 && i % 128 == 0)
p.StandardInput.WriteLine ();
}

p.StandardInput.Close ();

p.WaitForExit ();
}
}
#endif // MONO_FEATURE_PROCESS_START
Expand Down

0 comments on commit e19a2e2

Please sign in to comment.