Skip to content

Commit

Permalink
fix: run_as_daemon should always be enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jm33-m0 committed Aug 4, 2023
1 parent aaea274 commit 11a3979
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions core/cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,20 @@ func main() {
}
}

if !do_not_touch_argv {
// always daemonize unless verbose is specified
run_as_daemon := !verbose &&
// don't daemonize if we're already daemonized
os.Getenv("DAEMON") != "true"

if run_as_daemon {
os.Setenv("DAEMON", "true") // mark as daemonized
cmd := exec.Command(os.Args[0])
err = cmd.Start()
if err != nil {
log.Fatalf("Daemonize: %v", err)
}
os.Exit(0)
// always daemonize unless verbose is specified
run_as_daemon := !verbose &&
// don't daemonize if we're already daemonized
os.Getenv("DAEMON") != "true" &&
// argv has to stay untouched, otherwise we cannot start a new process
do_not_touch_argv
if run_as_daemon {
os.Setenv("DAEMON", "true") // mark as daemonized
cmd := exec.Command(os.Args[0])
err = cmd.Start()
if err != nil {
log.Fatalf("Daemonize: %v", err)
}
os.Exit(0)
}

osArgs := os.Args
Expand Down

0 comments on commit 11a3979

Please sign in to comment.