Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8061e36

Browse files
committed
Fix Shell Run
1 parent 6249d5f commit 8061e36

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/ST.Client.Desktop.Linux/Services/Implementation/LinuxPlatformServiceImpl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public async void SystemHibernate(int waitSecond = 30)
185185
await Task.Delay(waitSecond);
186186
RunShell($"echo \"{SystemUserPassword}\" | sudo sh -c \" echo disk > /sys/pwoer/state\"");
187187
}
188-
private string RunShell(string shell, bool isAdmin = false)
188+
private string RunShell(string shell)
189189
{
190190
try
191191
{
@@ -226,7 +226,7 @@ public async void TryGetSystemUserPassword(sbyte retry_count = 4)
226226
var pwd = await TextBoxWindowViewModel.ShowDialogAsync(vm);
227227
if (!string.IsNullOrWhiteSpace(pwd))
228228
{
229-
if (!string.IsNullOrWhiteSpace(RunShell($"echo \"{pwd}\" | sudo -S sh -c \"sudo -n true\"", true)))
229+
if (!string.IsNullOrWhiteSpace(RunShell($"echo \"{pwd}\" | sudo -S sh -c \"sudo -n true\"")))
230230
{
231231
SystemUserPassword = pwd;
232232
}

src/ST.Client.Desktop.Mac/Internals/UnixHelper.RunShellAsync.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,19 @@ public static string RunShell(string shell)
9898
try
9999
{
100100
using var p = new Process();
101-
p.StartInfo.FileName = BinBash;
102-
p.StartInfo.Arguments = shell;
101+
p.StartInfo.FileName = UnixHelper.BinBash;
102+
p.StartInfo.Arguments = "";
103103
p.StartInfo.RedirectStandardOutput = true;
104+
p.StartInfo.RedirectStandardInput = true;
104105
p.StartInfo.UseShellExecute = false;
105-
p.StartInfo.CreateNoWindow = true;
106106
p.Start();
107+
p.StandardInput.WriteLine(shell);
108+
p.StandardInput.Close();
107109
string result = p.StandardOutput.ReadToEnd();
110+
p.StandardOutput.Close();
108111
p.WaitForExit();
109112
p.Close();
113+
p.Dispose();
110114
return result;
111115
}
112116
catch (Exception e)

0 commit comments

Comments
 (0)