rclone/cmd/mountlib/daemon_unix.go

32 lines
469 B
Go
Raw Normal View History

// Daemonization interface for Unix variants only
// +build !windows,!plan9,!js
package mountlib
import (
"log"
2018-12-04 11:11:57 +01:00
daemon "github.com/sevlyar/go-daemon"
)
func startBackgroundMode() bool {
cntxt := &daemon.Context{}
d, err := cntxt.Reborn()
if err != nil {
log.Fatalln(err)
}
if d != nil {
return true
}
defer func() {
if err := cntxt.Release(); err != nil {
log.Printf("error encountered while killing daemon: %v", err)
}
}()
return false
}