Skip to content

Commit eeea49a

Browse files
committed
Send SIGTERM before closing pipes in ACP shutdown
Reorder the shutdown sequence to send SIGTERM first, giving the agent a chance to shutdown gracefully before losing I/O.
1 parent 0e5c2a0 commit eeea49a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/httpapi/setup.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,11 @@ func SetupACP(ctx context.Context, config SetupACPConfig) (*SetupACPResult, erro
105105
select {
106106
case <-ctx.Done():
107107
logger.Info("Context done, closing ACP agent")
108-
_ = stdin.Close()
109-
_ = stdout.Close()
110108
// Try graceful shutdown first
111109
_ = cmd.Process.Signal(syscall.SIGTERM)
110+
// Then close pipes
111+
_ = stdin.Close()
112+
_ = stdout.Close()
112113
// Force kill after timeout
113114
time.AfterFunc(5*time.Second, func() {
114115
_ = cmd.Process.Kill()

0 commit comments

Comments
 (0)