Example #1
0
        /// <summary>
        /// Creates a new instance of <see cref="ChildProcess"/>.
        /// </summary>
        /// <param name="pid">The process ID of the console process.</param>
        /// <param name="options">The <see cref="ChildProcessOptions"/> to use when accessing the console input and output of the child process.</param>
        /// <remarks>This constructor is used to manipulate console I/O for a process that is already running.</remarks>
        public ChildProcess(int pid, ChildProcessOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            this.Options = options;

            try
            {
                this.proxy.Start();
                this.proxy.CommandPipeWriter.Write((byte)ProxyCommand.SetPid);
                this.proxy.CommandPipeWriter.Write(pid);
                this.proxy.CommandPipeWriter.Flush();

                this.readResponseAndThrow();
            }
            catch (Exception)
            {
                this.Dispose();
                throw;
            }
        }
Example #2
0
        /// <summary>
        /// Creates a new instance of <see cref="ChildProcess"/>.
        /// </summary>
        /// <param name="filePath">The path to the child process. The semantics in terms of how relative paths are handled are the same as <see cref="System.Diagnostics.ProcessStartInfo.FileName"/> with <see cref="System.Diagnostics.ProcessStartInfo.UseShellExecute"/> set to <b>false</b>.</param>
        /// <param name="arguments">The command line arguments for the child process.</param>
        /// <param name="workingDirectory">The working directory for the child process.</param>
        /// <param name="options">The <see cref="ChildProcessOptions"/> to use when accessing the console input and output of the child process.</param>
        public ChildProcess(string filePath, string arguments, string workingDirectory, ChildProcessOptions options)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException("filePath");
            }
            if (arguments == null)
            {
                throw new ArgumentNullException("arguments");
            }
            if (workingDirectory == null)
            {
                throw new ArgumentNullException("workingDirectory");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            this.Options = options;

            try
            {
                this.proxy.Start();
                this.proxy.CommandPipeWriter.Write((byte)ProxyCommand.StartProcess);
                this.proxy.CommandPipeWriter.Write(filePath);
                this.proxy.CommandPipeWriter.Write(arguments);
                this.proxy.CommandPipeWriter.Write(workingDirectory);
                this.proxy.CommandPipeWriter.Flush();

                this.readResponseAndThrow();
            }
            catch (Exception)
            {
                this.Dispose();
                throw;
            }
        }
Example #3
0
 /// <summary>
 /// Creates a new instance of <see cref="ChildProcess"/>.
 /// </summary>
 /// <param name="filePath">The path to the child process. The semantics in terms of how relative paths are handled are the same as <see cref="System.Diagnostics.ProcessStartInfo.FileName"/> with <see cref="System.Diagnostics.ProcessStartInfo.UseShellExecute"/> set to <b>false</b>.</param>
 /// <param name="arguments">The command line arguments for the child process.</param>
 /// <param name="options">The <see cref="ChildProcessOptions"/> to use when accessing the console input and output of the child process.</param>
 public ChildProcess(string filePath, string arguments, ChildProcessOptions options) : this(filePath, arguments, Environment.CurrentDirectory, options)
 {
 }
Example #4
0
 /// <summary>
 /// Creates a new instance of <see cref="ChildProcess"/>.
 /// </summary>
 /// <param name="filePath">The path to the child process. The semantics in terms of how relative paths are handled are the same as <see cref="System.Diagnostics.ProcessStartInfo.FileName"/> with <see cref="System.Diagnostics.ProcessStartInfo.UseShellExecute"/> set to <b>false</b>.</param>
 /// <param name="options">The <see cref="ChildProcessOptions"/> to use when accessing the console input and output of the child process.</param>
 public ChildProcess(string filePath, ChildProcessOptions options) : this(filePath, String.Empty, options)
 {
 }