[Mono-list] System.Diagnostics.Process.StartInfo.Arguments
Nils Andresen
andresen.nils at googlemail.com
Tue Sep 1 14:45:16 EDT 2009
Hi.
I'm new to this list so I'm not sure if I'm wrong here...
But calling
> export.StartInfo.RedirectStandardOutput = true;
> export.WaitForExit();
> export.StandardOutput.ReadToEnd()
can lead to a deadlock (at least when using .net framework...).
When export.StandardOutput buffer is full the called thread will wait for
the buffer to clear while the calling thread will wait for the called thread
to exit....
Yours,
Nils
2009/9/1 Fred Patterson <fpatterson at novell.com>
> Chris,
>
> I was able to fix it. You got me started down the right path.
> I still couldn't get the argument variable to work with the 1>output.log,
> however, I was able to work around it.
> The below code creates a file called output.log in the current path.
>
> Thanks again.
>
>
> System.Diagnostics.Process export = new
> System.Diagnostics.Process();
> export.EnableRaisingEvents = false;
> export.StartInfo.RedirectStandardOutput = true;
> export.StartInfo.RedirectStandardError = true;
> export.StartInfo.UseShellExecute = false;
> export.StartInfo.FileName = "/bin/sh";
> export.StartInfo.Arguments = "discover.sh";
>
> export.Start();
>
> export.WaitForExit();
> if (0 != export.ExitCode)
> Console.WriteLine("Error");
>
> TextWriter output = new
> StreamWriter("output.log");
>
> output.WriteLine(export.StandardOutput.ReadToEnd());
> output.Close();
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20090901/77753957/attachment.html
More information about the Mono-list
mailing list