Skip to content

Commit dda58bf

Browse files
Repair signal handlers after FFI shutdown
Reapply SA_ONSTACK after libuv tears down its child watcher so subsequent Go subprocess cleanup cannot crash. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 447feac4-35df-4c0b-ab34-00789ad78da7
1 parent 2ed51a5 commit dda58bf

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

go/internal/ffihost/ffihost.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ func (h *Host) Start() error {
229229
outboundTargets.Delete(callbackToken)
230230
h.callbackToken = 0
231231
h.lib.hostShutdown(h.serverID)
232+
rearmForeignSignalHandlers(h.lib.handle)
232233
h.serverID = 0
233234
return fmt.Errorf("copilot_runtime_connection_open failed")
234235
}
@@ -364,6 +365,10 @@ func (h *Host) Dispose() {
364365
}
365366
if serverID != 0 {
366367
h.lib.hostShutdown(serverID)
368+
// libuv may restore a previously saved SIGCHLD action while tearing down
369+
// its final child watcher, so repair the process-wide handler again after
370+
// shutdown before Go reaps another os/exec child.
371+
rearmForeignSignalHandlers(h.lib.handle)
367372
}
368373
h.recv.Close()
369374
}

0 commit comments

Comments
 (0)