Files
newt/reexec_unix.go
Owen 7ff97eda51 Add restart endpoint
Former-commit-id: 734542c3ed
2026-05-28 15:38:09 -07:00

22 lines
537 B
Go

//go:build !windows
package main
import (
"fmt"
"os"
"syscall"
)
// reexec replaces the current process image with a fresh copy of itself,
// preserving all arguments and environment variables. On success it never
// returns (execve replaces the process in-place). On failure it returns an
// error describing why the exec could not be performed.
func reexec() error {
exe, err := os.Executable()
if err != nil {
return fmt.Errorf("failed to get executable path: %w", err)
}
return syscall.Exec(exe, os.Args, os.Environ())
}