fix: Add Windows build support for daemon command
- Split platform-specific daemon process configuration into separate files - daemon_unix.go: Uses Setsid for Unix/Linux/macOS - daemon_windows.go: Uses CREATE_NEW_PROCESS_GROUP for Windows - Fixes compilation error: "unknown field Setsid in struct literal" This allows bd.exe to build successfully on Windows while maintaining proper daemon behavior on all platforms. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -262,7 +262,7 @@ func startDaemon(interval time.Duration, autoCommit, autoPush bool, logFile, pid
|
|||||||
|
|
||||||
cmd := exec.Command(exe, args...)
|
cmd := exec.Command(exe, args...)
|
||||||
cmd.Env = append(os.Environ(), "BD_DAEMON_FOREGROUND=1")
|
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)
|
devNull, err := os.OpenFile(os.DevNull, os.O_RDWR, 0)
|
||||||
if err != nil {
|
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