mirror of
https://github.com/rclone/rclone.git
synced 2024-12-26 08:58:58 +01:00
32 lines
451 B
Go
32 lines
451 B
Go
|
// Daemonization interface for Unix variants only
|
||
|
|
||
|
// +build !windows
|
||
|
|
||
|
package mountlib
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
|
||
|
"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
|
||
|
}
|