Merge PR #78: Add Windows build support for daemon command
This commit is contained in:
@@ -321,7 +321,7 @@ func startDaemon(interval time.Duration, autoCommit, autoPush bool, logFile, pid
|
||||
|
||||
cmd := exec.Command(exe, args...)
|
||||
cmd.Env = append(os.Environ(), "BD_DAEMON_FOREGROUND=1")
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||
configureDaemonProcess(cmd)
|
||||
|
||||
devNull, err := os.OpenFile(os.DevNull, os.O_RDWR, 0)
|
||||
if err != nil {
|
||||
|
||||
13
cmd/bd/daemon_unix.go
Normal file
13
cmd/bd/daemon_unix.go
Normal file
@@ -0,0 +1,13 @@
|
||||
//go:build unix || linux || darwin
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// configureDaemonProcess sets up platform-specific process attributes for daemon
|
||||
func configureDaemonProcess(cmd *exec.Cmd) {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||
}
|
||||
16
cmd/bd/daemon_windows.go
Normal file
16
cmd/bd/daemon_windows.go
Normal file
@@ -0,0 +1,16 @@
|
||||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// configureDaemonProcess sets up platform-specific process attributes for daemon
|
||||
func configureDaemonProcess(cmd *exec.Cmd) {
|
||||
// Windows doesn't support Setsid, use CREATE_NEW_PROCESS_GROUP instead
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user