Skip to content

Commit 85d1065

Browse files
committed
fix(bridge): portable killSelf for win32 cross builds; build whole bridge package
The win32 release legs failed to compile: the orphan watchdog used syscall.Kill/syscall.SIGKILL, which do not exist on Windows. Split into build-tagged killSelf (SIGKILL on Unix, TerminateProcess via os.Process.Kill on Windows). build-bridge.js now builds the bridge package ('.') instead of the single bridge.go file so the platform- split files are included — the previous single-file build worked only because everything lived in bridge.go. Also anchor the root .gitignore 'bridge/' rule to /typescript-go/bridge/ — it was shadowing patches/typescript-go/overlay/bridge/ sources. darwin-x64 leg in the same run was not hung, just queued on macos-13 runner scarcity.
1 parent 9f13ceb commit 85d1065

5 files changed

Lines changed: 34 additions & 6 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ node_modules/
55
lib/
66
native/
77
vendor/
8-
bridge/
8+
/typescript-go/bridge/

‎patches/typescript-go/overlay/bridge/bridge.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
"strconv"
3535
"strings"
3636
"sync"
37-
"syscall"
3837
"time"
3938
"unsafe"
4039

@@ -165,10 +164,11 @@ func startOrphanWatchdog() {
165164
for {
166165
time.Sleep(2 * time.Second)
167166
if os.Getppid() == 1 {
168-
// Parent died. SIGKILL ourselves: skips Node's atexit
167+
// Parent died. Hard-kill ourselves: skips Node's atexit
169168
// (ResetStdio) entirely, so the storm can never re-arm,
170-
// and the OS reclaims all session memory.
171-
_ = syscall.Kill(os.Getpid(), syscall.SIGKILL)
169+
// and the OS reclaims all session memory. killSelf is
170+
// platform-split (syscall.Kill is Unix-only).
171+
killSelf()
172172
}
173173
}
174174
}()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build !windows
2+
3+
package main
4+
5+
import (
6+
"os"
7+
"syscall"
8+
)
9+
10+
// killSelf hard-kills this process, skipping Node's atexit (ResetStdio).
11+
func killSelf() {
12+
_ = syscall.Kill(os.Getpid(), syscall.SIGKILL)
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build windows
2+
3+
package main
4+
5+
import "os"
6+
7+
// killSelf hard-kills this process (TerminateProcess on Windows — syscall.Kill
8+
// does not exist there). Same intent as the Unix SIGKILL path: skip atexit.
9+
func killSelf() {
10+
if p, err := os.FindProcess(os.Getpid()); err == nil {
11+
_ = p.Kill()
12+
}
13+
}

‎tools/build-bridge.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ fs.mkdirSync(nativeDir, { recursive: true });
1919
const args = ["build", "-tags=noembed", "-buildmode=c-shared"];
2020
// TNB_STRIP=1: drop debug symbols for shipped binaries (release matrix).
2121
if (process.env.TNB_STRIP === "1") args.push("-ldflags=-s -w");
22-
args.push("-o", outPath, "bridge.go");
22+
// Build the package (not just bridge.go) so platform-split files
23+
// (killself_unix.go / killself_windows.go) are included.
24+
args.push("-o", outPath, ".");
2325

2426
const r = spawnSync("go", args, { cwd: bridgeDir, stdio: "inherit" });
2527
if (r.status !== 0) process.exit(r.status ?? 1);

0 commit comments

Comments
 (0)