-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fixed deadlocks due to redirected outputs from child dotnet proc…
…esses.
- Loading branch information
1 parent
670485b
commit d87a8ff
Showing
7 changed files
with
67 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// <copyright file="StreamPipe.cs" company="Heleonix - Hennadii Lutsyshyn"> | ||
// Copyright (c) Heleonix - Hennadii Lutsyshyn. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the repository root for full license information. | ||
// </copyright> | ||
|
||
namespace Heleonix.Build; | ||
|
||
/// <summary> | ||
/// The pipe to read redirected output. | ||
/// </summary> | ||
internal sealed class StreamPipe | ||
{ | ||
private const int BufferSize = 2048; | ||
|
||
private readonly TextReader source; | ||
|
||
private readonly TextWriter destination; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="StreamPipe"/> class. | ||
/// </summary> | ||
/// <param name="source">The source.</param> | ||
/// <param name="destination">The destination.</param> | ||
public StreamPipe(TextReader source, TextWriter destination) | ||
{ | ||
this.source = source; | ||
this.destination = destination; | ||
} | ||
|
||
/// <summary> | ||
/// Connects the pipe. | ||
/// </summary> | ||
public void Connect() | ||
{ | ||
System.Threading.Tasks.Task.Run( | ||
async () => | ||
{ | ||
var buffer = new char[StreamPipe.BufferSize]; | ||
while (true) | ||
{ | ||
var count = await this.source.ReadAsync(buffer, 0, BufferSize); | ||
if (count <= 0) | ||
{ | ||
break; | ||
} | ||
await this.destination.WriteAsync(buffer, 0, count); | ||
await this.destination.FlushAsync(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters