// SPDX-License-Identifier: GPL-3.0-or-later

//go:build windows

package cli

import (
	"os"
	"syscall"
)

// daemonProcAttr returns platform-specific process attributes for daemonizing.
// On Windows, we use CREATE_NEW_PROCESS_GROUP to detach the child process.
func daemonProcAttr() *syscall.SysProcAttr {
	return &syscall.SysProcAttr{
		CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP,
	}
}

// sendStopSignal sends a stop signal to the process.
// On Windows, there is no SIGTERM; we use Kill() as the closest equivalent.
func sendStopSignal(process *os.Process) error {
	return process.Kill()
}

// checkProcessAlive checks whether a process is still running.
// On Windows, FindProcess always succeeds, so we attempt a zero-signal equivalent.
// We simply return nil since Windows doesn't support signal 0 — the caller
// should rely on process.Wait() or other mechanisms. A best-effort approach
// is to try to open the process.
func checkProcessAlive(_ *os.Process) error {
	// On Windows, os.FindProcess doesn't fail for dead processes.
	// Returning nil means "assumed alive" — the HTTP health check
	// in runDaemonStatus will catch actual failures.
	return nil
}
