dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] Problem with the Process class and redirection.


From: jscottb
Subject: [Pnet-developers] Problem with the Process class and redirection.
Date: Fri, 10 Oct 2003 21:37:39 -0500 (EST)

Hello,

I'm trying to use the the Process class to start a CGI program from a web
server I am writing.  If I do:

using System;
using System.Diagnostics;

class Test {
   public static void Main()
   {
      Process proc = new Process ( );
      proc.StartInfo.FileName = "/bin/ls";

      // Set to false and it works ok.
      proc.StartInfo.RedirectStandardOutput = true;
      proc.StartInfo.UseShellExecute = false;
      proc.StartInfo.Arguments = "";
      proc.Start ( );
      proc.WaitForExit ( );
   }
}

If you execute the above code you get:

 Uncaught exception: System.UnauthorizedAccessException: Incorrect access
 mode specified for file handle
         at System.IO.FileStream..ctor(IntPtr, FileAccess, Boolean, Int32,
 Boolean) in ./System/IO/FileStream.cs:195
         at System.IO.FileStream..ctor(IntPtr, FileAccess, Boolean)
         at System.Diagnostics.Process.Start() in ./Diagnostics/Process.cs:957
         at Test.Main() in ./testproc.cs:12

If you do not redirect the std's, it runs the process, but no stdin/stdout
redirection. I have tested this with 0.5.12 and the current CVS versions
of all the tools and get the same results.

My platform info:

Linix x86 Kernel 2.4.21 and glib6

thanks,
scott



reply via email to

[Prev in Thread] Current Thread [Next in Thread]