//go:build unix

package proc

import (
	"syscall"
)

func sweepRepo(repoRoot string) {
	targets := RepoDevProcessTargets(repoRoot, ListProcesses())
	seenPGID := map[int]bool{}
	for _, process := range targets {
		if process.PGID > 0 && process.PGID != syscall.Getpgrp() && !seenPGID[process.PGID] {
			seenPGID[process.PGID] = true
			terminateProcessGroup(process.PGID, nil, syscall.Kill, DefaultStopTimeout)
			continue
		}
		terminatePIDTree(process.PID, nil, syscall.Kill, DefaultStopTimeout)
	}
}
