private ChildProcess( SafeProcessHandle processHandle, Stream standardInput, Stream standardOutput, Stream standardError) { this._processHandle = processHandle; this._standardInput = standardInput; this._standardOutput = standardOutput; this._standardError = standardError; // In Windows it is easy to get a WaitHandle from a process handle... What about Linux? this._waitHandle = new ChildProcessWaitHandle(HandlePal.ToWaitHandle(processHandle)); }
private ProcessPipeline( ProcessEntry[] entries, Stream standardInput, Stream standardOutput, Stream standardError) { this._entries = entries; this._standardInput = standardInput; this._standardOutput = standardOutput; this._standardError = standardError; try { int validProcessCount = 0; for (int i = 0; i < _entries.Length; i++) { if (_entries[i].ProcessHandle != null) { validProcessCount++; } } if (validProcessCount == 0) { this._waitHandles = Array.Empty <WaitHandle>(); this._hasExitCodes = true; } else { this._waitHandles = new WaitHandle[validProcessCount]; int waitHandleIndex = 0; for (int i = 0; i < _entries.Length; i++) { if (_entries[i].ProcessHandle != null) { _waitHandles[waitHandleIndex++] = new ChildProcessWaitHandle(HandlePal.ToWaitHandle(_entries[i].ProcessHandle)); } } } } catch { foreach (var h in _waitHandles) { h?.Dispose(); } throw; } }