private static unsafe void Write(SafeFileHandle fd, byte* bufPtr, int count) { while (count > 0) { int bytesWritten = Interop.Sys.Write(fd, bufPtr, count); if (bytesWritten < 0) { Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); if (errorInfo.Error == Interop.Error.EPIPE) { // Broken pipe... likely due to being redirected to a program // that ended, so simply pretend we were successful. return; } else { // Something else... fail. throw Interop.GetExceptionForIoErrno(errorInfo); } } count -= bytesWritten; bufPtr += bytesWritten; } }
public override void Write(byte[] buffer, int offset, int count) { ValidateWrite(buffer, offset, count); ConsolePal.Write(_handle, buffer, offset, count); }