Related to #5 (Large text not sending).
I've been investigating a more severe version of this problem. tmux send-keys -l can hang indefinitely (not just slow — the process never exits), which blocks the entire listener getUpdates loop and prevents receiving any new Telegram messages.
What happens
tmux send-keys -t <target> -l "<text>" is called to paste text into Claude Code
- The tmux client enters
proc_loop() waiting for the server to respond
- If Claude Code is not reading stdin fast enough, the PTY kernel buffer fills up (~4096 bytes on macOS)
- The tmux server's
bufferevent_write() gets EAGAIN, stalling the event loop
- The
send-keys client process never exits — proc_loop() has no timeout mechanism
- Our Go code calls
cmd.Run() which blocks forever waiting for the process
I found 5 stuck tmux send-keys processes on my machine, one running for 8+ hours.
Ghost messages
After killing the stuck processes, data already written to the tmux server's buffer remains in the PTY kernel buffer. When Claude Code eventually reads stdin, it processes this stale data as new prompts — executing commands the user never sent. This is a security concern since Claude may execute dangerous operations from ghost input.
What I've tried
- Added timeout via
exec.CommandContext — prevents listener hang, but doesn't prevent ghost messages
- Sending Escape + Ctrl-U before each send-keys — clears TUI input, but can't flush kernel PTY buffer
- The PTY kernel buffer on macOS is not user-configurable
tmux internals
Environment
- macOS (Darwin), tmux 3.5a, Go
- Happens most often with photo messages (longer text + 2s delay before send-keys)
Any ideas on how to solve the ghost message problem? I've been thinking about this for a while and haven't found a clean solution.
Related to #5 (Large text not sending).
I've been investigating a more severe version of this problem.
tmux send-keys -lcan hang indefinitely (not just slow — the process never exits), which blocks the entire listenergetUpdatesloop and prevents receiving any new Telegram messages.What happens
tmux send-keys -t <target> -l "<text>"is called to paste text into Claude Codeproc_loop()waiting for the server to respondbufferevent_write()getsEAGAIN, stalling the event loopsend-keysclient process never exits —proc_loop()has no timeout mechanismcmd.Run()which blocks forever waiting for the processI found 5 stuck
tmux send-keysprocesses on my machine, one running for 8+ hours.Ghost messages
After killing the stuck processes, data already written to the tmux server's buffer remains in the PTY kernel buffer. When Claude Code eventually reads stdin, it processes this stale data as new prompts — executing commands the user never sent. This is a security concern since Claude may execute dangerous operations from ghost input.
What I've tried
exec.CommandContext— prevents listener hang, but doesn't prevent ghost messagestmux internals
proc_loop()in proc.c has no timeoutsend-keysvery slow on FreeBSD tmux/tmux#1812, tmux frozen, ls or attach freezing as well tmux/tmux#2324Environment
Any ideas on how to solve the ghost message problem? I've been thinking about this for a while and haven't found a clean solution.