Ported remaining netns.sh

- Ported remaining netns.sh tests
- Begin work on generic implementation of bind interface
This commit is contained in:
Mathias Hall-Andersen
2017-11-17 17:25:45 +01:00
parent e1227d3af4
commit fa399a91d5
13 changed files with 194 additions and 28 deletions
+9 -4
View File
@@ -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,
)