mirror of
https://github.com/2dust/v2rayN.git
synced 2026-04-14 19:45:45 +00:00
Replace core killing script with a one-liner
This commit is contained in:
parent
bcef55a6bb
commit
d5267d0b69
2 changed files with 13 additions and 16 deletions
|
|
@ -68,19 +68,19 @@ public class CoreAdminManager
|
|||
|
||||
try
|
||||
{
|
||||
var shellFileName = Utils.IsMacOS() ? Global.KillAsSudoOSXShellFileName : Global.KillAsSudoLinuxShellFileName;
|
||||
var shFilePath = await FileUtils.CreateLinuxShellFile("kill_as_sudo.sh", EmbedUtils.GetEmbedText(shellFileName), true);
|
||||
if (shFilePath.Contains(' '))
|
||||
if (Utils.IsLinux())
|
||||
{
|
||||
shFilePath = shFilePath.AppendQuotes();
|
||||
var procService = new ProcessService(
|
||||
fileName: "/usr/bin/sudo",
|
||||
arguments: "-u#785 /usr/bin/pkill --uid 785 --exact sing-box",
|
||||
workingDirectory: Utils.GetBinConfigPath(),
|
||||
displayLog: true,
|
||||
redirectInput: false,
|
||||
environmentVars: null,
|
||||
updateFunc: null
|
||||
);
|
||||
await procService.StartAsync(AppManager.Instance.LinuxSudoPwd);
|
||||
}
|
||||
var arg = new List<string>() { "-c", $"sudo -S {shFilePath} {_linuxSudoPid}" };
|
||||
var result = await Cli.Wrap(Global.LinuxBash)
|
||||
.WithArguments(arg)
|
||||
.WithStandardInputPipe(PipeSource.FromString(AppManager.Instance.LinuxSudoPwd))
|
||||
.ExecuteBufferedAsync();
|
||||
|
||||
await UpdateFunc(false, result.StandardOutput.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -150,11 +150,8 @@ public class CoreManager
|
|||
{
|
||||
try
|
||||
{
|
||||
if (_linuxSudo)
|
||||
{
|
||||
await CoreAdminManager.Instance.KillProcessAsLinuxSudo();
|
||||
_linuxSudo = false;
|
||||
}
|
||||
await CoreAdminManager.Instance.KillProcessAsLinuxSudo();
|
||||
_linuxSudo = false;
|
||||
|
||||
if (_processService != null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue