示例#1
0
        internal static Process /*!*/ CreateProcess(RubyContext /*!*/ context, MutableString /*!*/ command,
                                                    bool redirectInput, bool redirectOutput, bool redirectErrorOutput)
        {
            string fileName, arguments;

            RubyProcess.GetExecutable(context.DomainManager.Platform, command.ToString(), out fileName, out arguments);
            Utils.Log(String.Format("Starting: '{0}' with args: '{1}'", fileName, arguments), "PROCESS");

            var p = new Process();

            p.StartInfo.FileName               = fileName;
            p.StartInfo.Arguments              = arguments;
            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.RedirectStandardInput  = redirectInput;
            p.StartInfo.RedirectStandardOutput = redirectOutput;
            p.StartInfo.RedirectStandardError  = redirectErrorOutput;
            try {
                p.Start();
            } catch (Exception e) {
                throw RubyExceptions.CreateENOENT(fileName, e);
            }

            context.ChildProcessExitStatus = new RubyProcess.Status(p);
            return(p);
        }
示例#2
0
文件: IoOps.cs 项目: ltwlf/IronSP
        public static RubyIO /*!*/ OpenPipe(
            RubyContext /*!*/ context,
            MutableString /*!*/ command,
            IOMode mode)
        {
            bool redirectStandardInput  = mode.CanWrite();
            bool redirectStandardOutput = mode.CanRead();

            Process process = RubyProcess.CreateProcess(context, command, redirectStandardInput, redirectStandardOutput, false);

            StreamReader reader = null;
            StreamWriter writer = null;

            if (redirectStandardOutput)
            {
                reader = process.StandardOutput;
            }

            if (redirectStandardInput)
            {
                writer = process.StandardInput;
            }

            return(new RubyIO(context, reader, writer, mode));
        }
示例#3
0
 public static RubyStruct /*!*/ Times(RubyClass /*!*/ self)
 {
     return(RubyProcess.GetTimes(self));
 }