aboutsummaryrefslogtreecommitdiffstats
path: root/src/daemon_linux.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/daemon_linux.go13
1 files changed, 9 insertions, 4 deletions
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,
)