mirror of
https://github.com/fosrl/newt.git
synced 2026-07-12 11:15:32 -05:00
22 lines
537 B
Go
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())
|
|
}
|