From fa399a91d5da9874cbf248e00db8dbd87b587e91 Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Fri, 17 Nov 2017 17:25:45 +0100 Subject: Ported remaining netns.sh - Ported remaining netns.sh tests - Begin work on generic implementation of bind interface --- src/daemon_linux.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/daemon_linux.go') diff --git a/src/daemon_linux.go b/src/daemon_linux.go index 8210f8b..e1aaede 100644 --- a/src/daemon_linux.go +++ b/src/daemon_linux.go @@ -2,20 +2,25 @@ package main import ( "os" + "os/exec" ) /* 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 */ - func Daemonize(attr *os.ProcAttr) error { + // I would like to use os.Executable, + // however this means dropping support for Go <1.8 + path, err := exec.LookPath(os.Args[0]) + if err != nil { + return err + } + argv := []string{os.Args[0], "--foreground"} argv = append(argv, os.Args[1:]...) process, err := os.StartProcess( - argv[0], + path, argv, attr, ) -- cgit v1.2.3