Skip to content

Commit fcf949f

Browse files
committed
fix: skip unrelated xray process
1 parent 4248952 commit fcf949f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

backend/xray/core.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,22 @@ func (c *Core) cleanupOrphanedProcesses() error {
300300
continue
301301
}
302302

303-
reason := "stale xray process from previous run"
304-
if procInfo.IsZombie {
305-
reason = "zombie xray process"
303+
// Only clean up processes we own (parented by this node process)
304+
// or zombies that have been reparented to init (no real parent).
305+
kill := false
306+
reason := ""
307+
if procInfo.IsZombie && (procInfo.PPID == 0 || procInfo.PPID == 1) {
308+
kill = true
309+
reason = "zombie xray process without parent"
306310
} else if procInfo.PPID == nodePID {
311+
kill = true
307312
reason = fmt.Sprintf("orphaned xray process with node as parent (PPID: %d)", procInfo.PPID)
308313
}
309314

315+
if !kill {
316+
continue
317+
}
318+
310319
log.Printf("%s %d (PPID: %d), killing it", reason, procInfo.PID, procInfo.PPID)
311320
if err := killProcessTree(procInfo.PID); err != nil {
312321
log.Printf("warning: failed to kill orphaned process %d: %v", procInfo.PID, err)

0 commit comments

Comments
 (0)