diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-11-19 13:19:07 +0100 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-11-19 13:19:07 +0100 |
commit | b5ae42349c4fd88022a63006060d72b03aa83b16 (patch) | |
tree | 18fecbdba6437003f574c15eddeb75bbed9980b3 /src/daemon_linux.go | |
parent | 5705a5e2efdcbbaffa5da00555b1afb3b4f9d2af (diff) | |
parent | 9ebab57c417d4fd19db6cf69f920a3adb1a1e092 (diff) |
Merge branch 'source-caching'
Diffstat (limited to 'src/daemon_linux.go')
-rw-r--r-- | src/daemon_linux.go | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/daemon_linux.go b/src/daemon_linux.go index 730f89e..e1aaede 100644 --- a/src/daemon_linux.go +++ b/src/daemon_linux.go @@ -2,29 +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 + } -func Daemonize() error { argv := []string{os.Args[0], "--foreground"} argv = append(argv, os.Args[1:]...) - attr := &os.ProcAttr{ - Dir: ".", - Env: os.Environ(), - Files: []*os.File{ - os.Stdin, - nil, - nil, - }, - } process, err := os.StartProcess( - argv[0], + path, argv, attr, ) |