Description
On Windows, the weclaw stop, weclaw status, and weclaw restart commands do not work correctly. The process management code in cmd/start.go uses Unix-only APIs (syscall.SIGTERM, p.Signal(0), pkill) that are either unavailable or behave differently on Windows.
Affected Commands
1. weclaw stop
- Prints "weclaw stopped" but does not actually kill the process
stopAllWeclaw() uses p.Signal(syscall.SIGTERM) which does not terminate processes on Windows
- Falls back to
exec.Command("pkill", ...) which is a Unix-only command — will fail silently on Windows
- Verified: after running
weclaw stop, Get-Process -Name weclaw still shows the process running
2. weclaw status
- Prints "weclaw is not running" even when the process is actively running
processExists() uses os.FindProcess(pid) + p.Signal(syscall.Signal(0))
- On Windows,
os.FindProcess always succeeds regardless of whether the process exists, and Signal(0) is not a valid operation
- Verified:
weclaw status reports "not running" while the process is actually processing WeChat messages
3. weclaw restart
- Inherits both broken behaviors from
stopAllWeclaw() and processExists()
- The 10-second wait loop (20 x 500ms) will always time out because
processExists() never returns false
Root Cause
All affected functions are in cmd/start.go:
processExists(pid int) bool (line 426-433) — uses Unix signal 0 probe
stopAllWeclaw() (line 436-452) — uses SIGTERM + pkill
Suggested Fix
processExists() on Windows: Use OpenProcess API via syscall, or fall back to tasklist /FI "PID eq %d"
stopAllWeclaw() on Windows: Use taskkill /F /PID %d or TerminateProcess instead of SIGTERM + pkill
- Use build tags (
//go:build windows) for platform-specific implementations, similar to the existing proc_windows.go
Environment
- OS: Windows 11 (amd64)
- WeClaw version: v0.7.1 (pre-built Windows binary)
- Reproduce: run
weclaw start, then weclaw status or weclaw stop
Workaround
Stop-Process -Name weclaw # instead of weclaw stop
Get-Process -Name weclaw # instead of weclaw status
Description
On Windows, the
weclaw stop,weclaw status, andweclaw restartcommands do not work correctly. The process management code incmd/start.gouses Unix-only APIs (syscall.SIGTERM,p.Signal(0),pkill) that are either unavailable or behave differently on Windows.Affected Commands
1.
weclaw stopstopAllWeclaw()usesp.Signal(syscall.SIGTERM)which does not terminate processes on Windowsexec.Command("pkill", ...)which is a Unix-only command — will fail silently on Windowsweclaw stop,Get-Process -Name weclawstill shows the process running2.
weclaw statusprocessExists()usesos.FindProcess(pid)+p.Signal(syscall.Signal(0))os.FindProcessalways succeeds regardless of whether the process exists, andSignal(0)is not a valid operationweclaw statusreports "not running" while the process is actually processing WeChat messages3.
weclaw restartstopAllWeclaw()andprocessExists()processExists()never returns falseRoot Cause
All affected functions are in
cmd/start.go:processExists(pid int) bool(line 426-433) — uses Unix signal 0 probestopAllWeclaw()(line 436-452) — usesSIGTERM+pkillSuggested Fix
processExists()on Windows: UseOpenProcessAPI via syscall, or fall back totasklist /FI "PID eq %d"stopAllWeclaw()on Windows: Usetaskkill /F /PID %dorTerminateProcessinstead ofSIGTERM+pkill//go:build windows) for platform-specific implementations, similar to the existingproc_windows.goEnvironment
weclaw start, thenweclaw statusorweclaw stopWorkaround