Skip to content

Commit

Permalink
Fixed KillXray function: added process termination wait using cmd.Wai…
Browse files Browse the repository at this point in the history
…t() to prevent accumulation of hanging Xray processes.
  • Loading branch information
kutovoys committed Sep 10, 2024
1 parent 8cde41e commit 0555048
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ func processConfigFile(configPath string, provider models.Provider) {
utils.LogResult(logData)
return
}

defer utils.KillXray(cmd)

time.Sleep(4 * time.Second)

proxyClient, err := utils.CreateProxyClient(logData.ProxyAddress)
Expand Down
5 changes: 4 additions & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ func RunXray(configPath string) (*exec.Cmd, error) {
}

func KillXray(cmd *exec.Cmd) error {
return cmd.Process.Kill()
if err := cmd.Process.Kill(); err != nil {
return err
}
return cmd.Wait()
}

func CreateProxyClient(proxyAddress string) (*http.Client, error) {
Expand Down

0 comments on commit 0555048

Please sign in to comment.