Skip to content

fix(hook): drop tee capture and use tcgetpgrp for fg process#15

Closed
moukrea wants to merge 3 commits intomainfrom
fix/hook-tee-capture
Closed

fix(hook): drop tee capture and use tcgetpgrp for fg process#15
moukrea wants to merge 3 commits intomainfrom
fix/hook-tee-capture

Conversation

@moukrea
Copy link
Copy Markdown
Owner

@moukrea moukrea commented Apr 14, 2026

Summary

Fixes remaining issues from the hook rework (#14):

  • Drop tee-based capture: exec > >(tee -a FILE) 2>&1 made stdout a pipe, breaking isatty() — TUI apps (nano, vim) couldn't initialize ncurses properly and keyboard shortcuts failed. The hook now only exports SNAG_SESSION with zero side effects. snag ls/cwd/ps/attach/send all work via /proc and the stolen master fd. Only snag output loses scrollback for hooked sessions.

  • Use tcgetpgrp for FG process detection: replaces the /proc scan heuristic (which returned ALL processes on the PTY, including background tee) with nix::unistd::tcgetpgrp(master_fd) — the kernel's authoritative answer for the foreground process group. Shows idle at the prompt, the actual command name when running something.

@moukrea moukrea closed this Apr 14, 2026
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.

1 participant