Skip to content

Stop attach sessions when perf exits#375

Open
jeet-dekivadia wants to merge 1 commit into
janestreet:masterfrom
jeet-dekivadia:codex/detach-when-perf-exits
Open

Stop attach sessions when perf exits#375
jeet-dekivadia wants to merge 1 commit into
janestreet:masterfrom
jeet-dekivadia:codex/detach-when-perf-exits

Conversation

@jeet-dekivadia

@jeet-dekivadia jeet-dekivadia commented May 30, 2026

Copy link
Copy Markdown

Summary

  • cache the perf recorder completion deferred so monitoring and final cleanup share a single waitpid
  • wake attach sessions when their recorder exits after the tracee terminates
  • tolerate ESRCH when snapshot or shutdown signals race an already-exited recorder

Why

In attach mode, killing the traced process makes perf record exit, but magic-trace only waits for Ctrl-C or a breakpoint snapshot. That leaves the command hanging after the tracee is gone. Sharing the recorder completion result also keeps shutdown from attempting a second reap.

Fixes #312

Validation

  • git diff --check
  • reviewed the attach wakeup and cached waitpid flow statically
  • verified Perf_tool_backend.Recording is the only Backend_intf.S.Recording implementation and that monitoring plus final cleanup share the same cached waitpid deferred

Signed-off-by: Jeet Dekivadia <jeet.university@gmail.com>
@jeet-dekivadia

Copy link
Copy Markdown
Author

Small follow-up for review context. This remains scoped to attach-session shutdown: Perf_tool_backend.Recording is the only recording implementation, and the patch caches its completion deferred so monitoring and cleanup observe the same single waitpid result. That lets a terminated tracee wake attach mode without changing Ctrl-C or breakpoint behavior, while the ESRCH handling only covers signal races after recorder exit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

magic-trace does not stop running on process SIGKILL

1 participant