diff options
| author | mhsanaei <ho3ein.sanaei@gmail.com> | 2025-09-14 21:04:12 +0300 |
|---|---|---|
| committer | mhsanaei <ho3ein.sanaei@gmail.com> | 2025-09-14 21:04:12 +0300 |
| commit | 46de886b53f0519d45d011090ac8eacc921d1134 (patch) | |
| tree | a85cbe4a4f16753a56f45b2282091fbbdb97367c /xray/process.go | |
| parent | 6d41320ed7994c651a4d0d3e5837c4f31000f541 (diff) | |
windows: error filter
Diffstat (limited to 'xray/process.go')
| -rw-r--r-- | xray/process.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/xray/process.go b/xray/process.go index 21ca5223..319f96d0 100644 --- a/xray/process.go +++ b/xray/process.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "runtime" + "strings" "syscall" "time" @@ -224,6 +225,15 @@ func (p *process) Start() (err error) { go func() { err := cmd.Run() if err != nil { + // On Windows, killing the process results in "exit status 1" which isn't an error for us + if runtime.GOOS == "windows" { + errStr := strings.ToLower(err.Error()) + if strings.Contains(errStr, "exit status 1") { + // Suppress noisy log on graceful stop + p.exitErr = err + return + } + } logger.Error("Failure in running xray-core:", err) p.exitErr = err } @@ -239,7 +249,7 @@ func (p *process) Stop() error { if !p.IsRunning() { return errors.New("xray is not running") } - + if runtime.GOOS == "windows" { return p.cmd.Process.Kill() } else { |
