EtherGuard-VPN/daemon.go

26 lines
348 B
Go
Raw Normal View History

package main
import (
"os"
)
2017-11-14 18:26:28 +01:00
func Daemonize(attr *os.ProcAttr) error {
2018-05-03 04:49:35 +02:00
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
}