mirror of
https://github.com/rclone/rclone.git
synced 2025-06-25 14:22:55 +02:00
mount: run rclone mount in the background - fixes #723
This commit is contained in:
32
cmd/mountlib/daemon_unix.go
Normal file
32
cmd/mountlib/daemon_unix.go
Normal file
@ -0,0 +1,32 @@
|
||||
// Daemonization interface for Unix variants only
|
||||
|
||||
// +build !windows
|
||||
// +build !darwin cgo
|
||||
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user