Pulse/internal/agentupdate/restart_unix.go
rcourtman d89ba45284 Fix Windows agent self-update restart failure
syscall.Exec is not supported on Windows, causing self-update to fail
with "failed to restart: not supported by windows".

Split restart logic into platform-specific files:
- restart_unix.go: Uses syscall.Exec for in-place process replacement
- restart_windows.go: Uses os.Exit(0) to let Windows SCM restart service

Related to #735
2025-11-30 12:02:43 +00:00

22 lines
430 B
Go

//go:build !windows
package agentupdate
import (
"fmt"
"os"
"syscall"
)
// restartProcess replaces the current process with a new instance.
// On Unix-like systems, this uses syscall.Exec for an in-place restart.
func restartProcess(execPath string) error {
args := os.Args
env := os.Environ()
if err := syscall.Exec(execPath, args, env); err != nil {
return fmt.Errorf("failed to restart: %w", err)
}
return nil
}