Apply changes from https://github.com/dotnet/runtime/commit/eb1756e97d23df13bc6fe798e...
[mono-project.git] / mono / tests / process-stress-1.cs
blob7f15a2f6e723f5e3380904ddfc6120843e31a667
2 using System;
3 using System.Diagnostics;
4 using System.Threading;
5 using System.Threading.Tasks;
7 class Driver
9 static void Main ()
11 for (int i = 0; i < 1000; ++i) {
12 ProcessStartInfo psi = new ProcessStartInfo () {
13 FileName = "echo",
14 Arguments = "hello",
15 RedirectStandardOutput = true,
16 UseShellExecute = false
19 Process p = Process.Start (psi);
21 ManualResetEvent mre = new ManualResetEvent (false);
23 Task t = Task.Run (() => {
24 mre.Set ();
25 p.BeginOutputReadLine ();
26 if (!p.WaitForExit (10000))
27 Environment.Exit (1);
28 });
30 if (!mre.WaitOne (10000))
31 Environment.Exit (2);
32 if (!p.WaitForExit (10000))
33 Environment.Exit (3);
35 if (!t.Wait (10000))
36 Environment.Exit (4);