wireguard-go/src/daemon_linux.go

28 lines
458 B
Go
Raw Normal View History

package main
import (
"os"
)
/* Daemonizes the process on linux
*
* This is done by spawning and releasing a copy with the --foreground flag
*
* TODO: Use env variable to spawn in background
*/
2017-11-14 17:26:28 +00:00
func Daemonize(attr *os.ProcAttr) error {
argv := []string{os.Args[0], "--foreground"}
argv = append(argv, os.Args[1:]...)
process, err := os.StartProcess(
argv[0],
argv,
attr,
)
if err != nil {
return err
}
process.Release()
return nil
}