From 3bd31d1534dbdaa1f42a82d24ecaf42a38b39c91 Mon Sep 17 00:00:00 2001 From: Alessandro Arzilli Date: Sun, 31 Aug 2025 18:04:02 +0200 Subject: [PATCH] service: remember that we attached in WaitFor attach mode (#4120) Save the attached to PID to the configuration when WaitFor is used so that we later know that we attached and behave identically to when the normal attach command is used, particularly with respect to killing the process on exit. Fixes #4119 --- service/debugger/debugger.go | 1 + service/rpc2/server.go | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/service/debugger/debugger.go b/service/debugger/debugger.go index cef67dcd..0a80b889 100644 --- a/service/debugger/debugger.go +++ b/service/debugger/debugger.go @@ -192,6 +192,7 @@ func New(config *Config, processArgs []string) (*Debugger, error) { err = noDebugErrorWarning(err) return nil, attachErrorMessage(d.config.AttachPid, err) } + d.config.AttachPid = d.target.Selected.Pid() case d.config.CoreFile != "": var err error diff --git a/service/rpc2/server.go b/service/rpc2/server.go index 32758306..60bcf2db 100644 --- a/service/rpc2/server.go +++ b/service/rpc2/server.go @@ -731,9 +731,7 @@ type AttachedToExistingProcessOut struct { // AttachedToExistingProcess returns whether we attached to a running process or not func (s *RPCServer) AttachedToExistingProcess(arg AttachedToExistingProcessIn, out *AttachedToExistingProcessOut) error { - if s.config.Debugger.AttachPid != 0 { - out.Answer = true - } + out.Answer = s.debugger.AttachPid() != 0 return nil }