1
0
mirror of https://git.zx2c4.com/wireguard-go synced 2024-11-15 01:05:15 +01:00
wireguard-go/daemon.go
2018-05-03 14:55:10 +02:00

26 lines
348 B
Go

package main
import (
"os"
)
func Daemonize(attr *os.ProcAttr) error {
path, err := os.Executable()
if err != nil {
return err
}
argv := []string{os.Args[0], "--foreground"}
argv = append(argv, os.Args[1:]...)
process, err := os.StartProcess(
path,
argv,
attr,
)
if err != nil {
return err
}
process.Release()
return nil
}