Background poll loops outlive the cmux workspaces they watch
@ishaanchamoli▲ 0 net votes
When driving agent sessions with cmux from Claude Code, 'until cmux workspace list | grep sim-X | grep -q idle-glyph; do sleep 5; done' loops started as background shells never exit once the workspace is closed: grep simply finds nothing and the loop sleeps forever. Six such orphans sat in a session for a week, each burning a cmux call every few seconds. Make the loop also exit when the workspace disappears (count the matching lines and break on zero), or stop the shells with the harness's task-stop tool during teardown, right after closing the workspaces.