internal SystemProcess Exec(string[] cmd, string[] envp, FilePath dir) { try { ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = cmd[0]; psi.Arguments = string.Join(" ", cmd, 1, cmd.Length - 1); if (dir != null) { psi.WorkingDirectory = dir.GetPath(); } psi.UseShellExecute = false; psi.RedirectStandardInput = true; psi.RedirectStandardError = true; psi.RedirectStandardOutput = true; psi.CreateNoWindow = true; if (envp != null) { foreach (string str in envp) { int index = str.IndexOf('='); psi.EnvironmentVariables[str.Substring(0, index)] = str.Substring(index + 1); } } return(SystemProcess.Start(psi)); } catch (System.ComponentModel.Win32Exception ex) { throw new IOException(ex.Message); } }
public static SystemProcess Start(this ProcessStartInfo si) { si.UseShellExecute = false; si.RedirectStandardInput = true; si.RedirectStandardError = true; si.RedirectStandardOutput = true; si.CreateNoWindow = true; return(SystemProcess.Start(si)); }
/// <exception cref="NGit.Errors.TransportException"></exception> public SshPushConnection(TransportGitSsh _enclosing) : base(_enclosing) { this._enclosing = _enclosing; try { this.process = this._enclosing.GetSession().Exec(this._enclosing.CommandFor(this. _enclosing.GetOptionReceivePack()), this._enclosing.GetTimeout()); MessageWriter msg = new MessageWriter(); this.SetMessageWriter(msg); InputStream rpErr = this.process.GetErrorStream(); this.errorThread = new StreamCopyThread(rpErr, msg.GetRawStream()); this.errorThread.Start(); this.Init(this.process.GetInputStream(), this.process.GetOutputStream()); } catch (TransportException err) { this.Close(); throw; } catch (IOException err) { this.Close(); throw new TransportException(this.uri, JGitText.Get().remoteHungUpUnexpectedly, err ); } try { this.ReadAdvertisedRefs(); } catch (NoRemoteRepositoryException notFound) { string msgs = this.GetMessages(); this._enclosing.CheckExecFailure(this.process.ExitValue(), this._enclosing.GetOptionReceivePack (), msgs); throw this._enclosing.CleanNotFound(notFound, msgs); } }
public override void Close() { base.Close(); if (this.receivePack != null) { try { this.receivePack.WaitFor(); } catch (Exception) { } finally { // Stop waiting and return anyway. this.receivePack = null; } } if (this.errorReaderThread != null) { try { this.errorReaderThread.Join(); } catch (Exception) { } finally { // Stop waiting and return anyway. this.errorReaderThread = null; } } }
/// <exception cref="NGit.Errors.TransportException"></exception> public ForkLocalPushConnection(TransportLocal _enclosing) : base(_enclosing) { this._enclosing = _enclosing; MessageWriter msg = new MessageWriter(); this.SetMessageWriter(msg); this.receivePack = this._enclosing.Spawn(this._enclosing.GetOptionReceivePack()); InputStream rpErr = this.receivePack.GetErrorStream(); this.errorReaderThread = new StreamCopyThread(rpErr, msg.GetRawStream()); this.errorReaderThread.Start(); InputStream rpIn = this.receivePack.GetInputStream(); OutputStream rpOut = this.receivePack.GetOutputStream(); rpIn = new BufferedInputStream(rpIn); rpOut = new SafeBufferedOutputStream(rpOut); this.Init(rpIn, rpOut); this.ReadAdvertisedRefs(); }
/// <exception cref="NGit.Errors.TransportException"></exception> public ForkLocalFetchConnection(TransportLocal _enclosing) : base(_enclosing ) { this._enclosing = _enclosing; MessageWriter msg = new MessageWriter(); this.SetMessageWriter(msg); this.uploadPack = this._enclosing.Spawn(this._enclosing.GetOptionUploadPack()); InputStream upErr = this.uploadPack.GetErrorStream(); this.errorReaderThread = new StreamCopyThread(upErr, msg.GetRawStream()); this.errorReaderThread.Start(); InputStream upIn = this.uploadPack.GetInputStream(); OutputStream upOut = this.uploadPack.GetOutputStream(); upIn = new BufferedInputStream(upIn); upOut = new BufferedOutputStream(upOut); this.Init(upIn, upOut); this.ReadAdvertisedRefs(); }