Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: Windows build — extract platform-specific process management

Mario628e43cad2f9
diff --git a/orchestrator_runtime.go b/orchestrator_runtime.go
index b303447e..d6665e8f 100644
--- a/orchestrator_runtime.go
+++ b/orchestrator_runtime.go
@@ -13,7 +13,6 @@ import (
"sort"
"strings"
"sync"
- "syscall"
"time"
)
@@ -69,7 +68,7 @@ func (o *Orchestrator) Launch(name, port string, headless bool) (*Instance, erro
"BRIDGE_NO_DASHBOARD": "true",
})
slog.Info("starting instance process", "id", id, "binary", o.binary, "port", port, "profile", profilePath)
- cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
+ setProcGroup(cmd)
logBuf := newRingBuffer(64 * 1024)
cmd.Stdout = logBuf
@@ -226,7 +225,7 @@ func (o *Orchestrator) Stop(id string) error {
return nil
}
- if err := syscall.Kill(-inst.PID, syscall.SIGTERM); err != nil {
+ if err := killProcessGroup(inst.PID, sigTERM); err != nil {
slog.Warn("failed to send SIGTERM to instance", "id", id, "pid", inst.PID, "err", err)
}
if waitForProcessExit(inst.PID, 3*time.Second) {
@@ -234,7 +233,7 @@ func (o *Orchestrator) Stop(id string) error {
return nil
}
- if err := syscall.Kill(-inst.PID, syscall.SIGKILL); err != nil {
+ if err := killProcessGroup(inst.PID, sigKILL); err != nil {
slog.Warn("failed to send SIGKILL to instance", "id", id, "pid", inst.PID, "err", err)
}
inst.cancel()
@@ -315,8 +314,7 @@ func waitForProcessExit(pid int, timeout time.Duration) bool {
}
func isProcessAlive(pid int) bool {
- err := syscall.Kill(pid, syscall.Signal(0))
- return err == nil || err == syscall.EPERM
+ return processAlive(pid)
}
func (o *Orchestrator) List() []Instance {
@@ -475,7 +473,7 @@ func (o *Orchestrator) ForceShutdown() {
for _, inst := range instances {
if inst.PID > 0 {
- _ = syscall.Kill(-inst.PID, syscall.SIGKILL)
+ _ = killProcessGroup(inst.PID, sigKILL)
}
if inst.cancel != nil {
inst.cancel()
diff --git a/pinchtab.exe b/pinchtab.exe
new file mode 100755
index 00000000..700b5806
Binary files /dev/null and b/pinchtab.exe differ
diff --git a/process_unix.go b/process_unix.go
new file mode 100644
index 00000000..eb852fc2
--- /dev/null
+++ b/process_unix.go
@@ -0,0 +1,29 @@
+//go:build !windows
+
+package main
+
+import (
+ "os/exec"
+ "syscall"
+)
+
+// setProcGroup puts the child process in its own process group.
+func setProcGroup(cmd *exec.Cmd) {
+ cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
+}
+
+// killProcessGroup sends a signal to the entire process group.
+func killProcessGroup(pid int, sig syscall.Signal) error {
+ return syscall.Kill(-pid, sig)
+}
+
+// processAlive checks if a process is still running.
+func processAlive(pid int) bool {
+ return syscall.Kill(pid, syscall.Signal(0)) == nil
+}
+
+// sigTERM is the termination signal.
+const sigTERM = syscall.SIGTERM
+
+// sigKILL is the kill signal.
+const sigKILL = syscall.SIGKILL
diff --git a/process_windows.go b/process_windows.go
new file mode 100644
index 00000000..fe133b1e
--- /dev/null
+++ b/process_windows.go
@@ -0,0 +1,38 @@
+//go:build windows
+
+package main
+
+import (
+ "os"
+ "os/exec"
+ "syscall"
+)
+
+// setProcGroup is a no-op on Windows (no process groups via Setpgid).
+func setProcGroup(cmd *exec.Cmd) {}
+
+// killProcessGroup kills the process on Windows (no group kill support).
+func killProcessGroup(pid int, _ syscall.Signal) error {
+ p, err := os.FindProcess(pid)
+ if err != nil {
+ return err
+ }
+ return p.Kill()
+}
+
+// processAlive checks if a process is still running on Windows.
+func processAlive(pid int) bool {
+ p, err := os.FindProcess(pid)
+ if err != nil {
+ return false
+ }
+ // On Windows, FindProcess always succeeds; we try to signal 0 equivalent.
+ err = p.Signal(syscall.Signal(0))
+ return err == nil
+}
+
+// sigTERM on Windows maps to a regular kill.
+const sigTERM = syscall.Signal(0xf)
+
+// sigKILL on Windows maps to a regular kill.
+const sigKILL = syscall.Signal(0x9)