diff --git a/workers/run.go b/workers/run.go index 9ca84150..da898237 100644 --- a/workers/run.go +++ b/workers/run.go @@ -9,7 +9,6 @@ import ( "runtime" "strconv" "strings" - "syscall" "time" "github.com/spf13/pflag" @@ -137,7 +136,7 @@ func (r *Runner) Run(ctx context.Context, baseDir string) error { if err != nil { return fmt.Errorf("failed creating command: %w", err) } - cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} // set process group ID for shutdown + setSysProcAttr(cmd) // set process group ID for shutdown // Direct logging output to provided logger, if available. if r.LoggingOptions.PreparedLogger != nil { @@ -243,10 +242,12 @@ func sendInterrupt(process *os.Process) error { if runtime.GOOS == "windows" { return process.Kill() } - return process.Signal(syscall.SIGINT) + return osSendInterrupt(process) } func sendKill(process *os.Process) error { - // shutting down the process group (ie including all child processes) - return syscall.Kill(-process.Pid, syscall.SIGKILL) + if runtime.GOOS == "windows" { + return process.Kill() + } + return osSendKill(process) } diff --git a/workers/run_unix.go b/workers/run_unix.go new file mode 100644 index 00000000..21149b3c --- /dev/null +++ b/workers/run_unix.go @@ -0,0 +1,22 @@ +//go:build !windows + +package workers + +import ( + "os" + "os/exec" + "syscall" +) + +func setSysProcAttr(cmd *exec.Cmd) { + cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} +} + +func osSendInterrupt(process *os.Process) error { + return process.Signal(syscall.SIGINT) +} + +func osSendKill(process *os.Process) error { + // Shut down the process group (including all child processes) + return syscall.Kill(-process.Pid, syscall.SIGKILL) +} diff --git a/workers/run_windows.go b/workers/run_windows.go new file mode 100644 index 00000000..74dbbe05 --- /dev/null +++ b/workers/run_windows.go @@ -0,0 +1,20 @@ +//go:build windows + +package workers + +import ( + "os" + "os/exec" +) + +func setSysProcAttr(cmd *exec.Cmd) { + // Setpgid is not supported on Windows; no-op +} + +func osSendInterrupt(process *os.Process) error { + return process.Kill() +} + +func osSendKill(process *os.Process) error { + return process.Kill() +} diff --git a/workers/typescript/protogen.js b/workers/typescript/protogen.js index 41508d90..2ac5485d 100644 --- a/workers/typescript/protogen.js +++ b/workers/typescript/protogen.js @@ -3,6 +3,11 @@ const { resolve } = require('path'); const { promisify } = require('util'); const glob = require('glob'); const { statSync, mkdirSync } = require('fs'); + +// Normalize path separators for glob (Windows uses backslashes, glob requires forward slashes) +function toGlobPath(p) { + return p.replace(/\\/g, '/'); +} const pbjs = require('protobufjs-cli/pbjs'); const pbts = require('protobufjs-cli/pbts'); @@ -73,7 +78,7 @@ async function compileProtos(dtsOutputFile, ...args) { async function main() { mkdirSync(outputDir, { recursive: true }); - const protoFiles = glob.sync(resolve(protoBaseDir, '**/*.proto')); + const protoFiles = glob.sync(toGlobPath(resolve(protoBaseDir, '**/*.proto'))); const protosMTime = Math.max(...protoFiles.map(mtime)); const genMTime = mtime(jsOutputFile);