From fbb5e9829323b83ab91521876370b75f4335c3d4 Mon Sep 17 00:00:00 2001 From: Yunsik kim Date: Sat, 18 Oct 2025 15:59:03 +0900 Subject: [PATCH] fix: Add Windows build support for daemon command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- cmd/bd/daemon.go | 2 +- cmd/bd/daemon_unix.go | 13 +++++++++++++ cmd/bd/daemon_windows.go | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 cmd/bd/daemon_unix.go create mode 100644 cmd/bd/daemon_windows.go diff --git a/cmd/bd/daemon.go b/cmd/bd/daemon.go index 025a5e35..53fc3b2b 100644 --- a/cmd/bd/daemon.go +++ b/cmd/bd/daemon.go @@ -262,7 +262,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 { diff --git a/cmd/bd/daemon_unix.go b/cmd/bd/daemon_unix.go new file mode 100644 index 00000000..c7611980 --- /dev/null +++ b/cmd/bd/daemon_unix.go @@ -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} +} diff --git a/cmd/bd/daemon_windows.go b/cmd/bd/daemon_windows.go new file mode 100644 index 00000000..5c6221e6 --- /dev/null +++ b/cmd/bd/daemon_windows.go @@ -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, + } +}