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

//go:build !windows

package cli

import (
	"os"
	"syscall"
)

// daemonProcAttr returns platform-specific process attributes for daemonizing.
func daemonProcAttr() *syscall.SysProcAttr {
	return &syscall.SysProcAttr{
		Setsid: true, // Create new session
	}
}

// sendStopSignal sends a graceful stop signal to the process.
func sendStopSignal(process *os.Process) error {
	return process.Signal(syscall.SIGTERM)
}

// checkProcessAlive checks whether a process is still running.
// Returns nil if the process is alive.
func checkProcessAlive(process *os.Process) error {
	return process.Signal(syscall.Signal(0))
}
