Skip to content

Commit 99d3052

Browse files
committed
fix processes hanging when waiting for input (fix #3848)
1 parent 83462d8 commit 99d3052

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/UniGetUI.Core.Settings/SettingsEngine_Names.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public enum K
7878
KillProcessesThatRefuseToDie,
7979
ManagerPaths,
8080
GitHubUserLogin,
81+
DisableNewProcessLineHandler,
8182

8283
Test1,
8384
Test2,
@@ -167,6 +168,7 @@ public static string ResolveKey(K key)
167168
K.KillProcessesThatRefuseToDie => "KillProcessesThatRefuseToDie",
168169
K.ManagerPaths => "ManagerPaths",
169170
K.GitHubUserLogin => "GitHubUserLogin",
171+
K.DisableNewProcessLineHandler => "DisableNewProcessLineHandler",
170172

171173
K.Test1 => "TestSetting1",
172174
K.Test2 => "TestSetting2",

src/UniGetUI.PackageEngine.Operations/AbstractProcessOperation.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Diagnostics;
22
using System.Text;
33
using UniGetUI.Core.Logging;
4+
using UniGetUI.Core.SettingsEngine;
45
using UniGetUI.Core.Tools;
56
using UniGetUI.PackageEngine.Enums;
67

@@ -94,13 +95,19 @@ protected override async Task<OperationVeredict> PerformOperation()
9495
}
9596

9697
process.Start();
98+
if (!Settings.Get(Settings.K.DisableNewProcessLineHandler))
99+
{
100+
await process.StandardInput.WriteLineAsync("\r\n\r\n\r\n\r\n");
101+
process.StandardInput.Close();
102+
}
97103
// process.BeginOutputReadLine();
98104
try { process.BeginErrorReadLine(); }
99105
catch (Exception ex) { Logger.Error(ex); }
100106

101107
StringBuilder currentLine= new();
102108
char[] buffer = new char[1];
103109
string? lastStringBeforeLF = null;
110+
104111
while ((await process.StandardOutput.ReadBlockAsync(buffer)) > 0)
105112
{
106113
char c = buffer[0];
@@ -110,21 +117,13 @@ protected override async Task<OperationVeredict> PerformOperation()
110117
{
111118
if (lastStringBeforeLF is not null)
112119
{
113-
if (lastStringBeforeLF.Contains("For the question below") || lastStringBeforeLF.Contains("Would remove:"))
114-
{
115-
await process.StandardInput.WriteLineAsync("");
116-
}
117120
Line(lastStringBeforeLF, LineType.Information);
118121
lastStringBeforeLF = null;
119122
}
120123
continue;
121124
}
122125

123126
string line = currentLine.ToString();
124-
if (line.Contains("For the question below") || line.Contains("Would remove:"))
125-
{
126-
await process.StandardInput.WriteLineAsync("");
127-
}
128127
Line(line, LineType.Information);
129128
currentLine.Clear();
130129
}

src/UniGetUI/Pages/SettingsPages/GeneralPages/Experimental.xaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@
5353

5454
<UserControl Height="16" />
5555

56-
<!--widgets:CheckboxCard
57-
x:Name="DisableUniGetUIElevatorToggle"
58-
BorderThickness="1,1,1,0"
59-
CornerRadius="8"
60-
SettingName="DisableUniGetUIElevator"
61-
StateChanged="ShowRestartBanner"
62-
Text="Enable the new UniGetUI-Branded UAC Elevator" /-->
6356
<widgets:SecureCheckboxCard
6457
x:Name="UseUserGSudoToggle"
6558
CornerRadius="8"
@@ -69,6 +62,12 @@
6962

7063
<UserControl Height="16" />
7164

65+
<widgets:CheckboxCard
66+
CornerRadius="8"
67+
SettingName="DisableNewProcessLineHandler"
68+
Text="Enable the new process input handler (StdIn automated closer)" />
69+
<UserControl Height="16" />
70+
7271
<widgets:CheckboxCard
7372
x:Name="DisableDownloadingNewTranslations"
7473
BorderThickness="1,1,1,0"

0 commit comments

Comments
 (0)