ttymap is a tool I built that draws a globe in the terminal with Braille ( previous post ). I made its engine "restartable while running." This post covers only why a restart is needed, and why that restart has to be a process restart.
Why make it restartable
A long-running ttymap was eating close to 200% CPU even when I wasn't touching it. The culprit was earcut , the polygon triangulation. Feed it a pathological (self-intersecting) polygon and it can fall into an infinite loop.
ttymap has a defense — a 200ms timeout that "gives up and swaps in another worker" — so the UI never freezes . But the worker it gave up on doesn't stop. It keeps spinning inside earcut, abandoned. So every time you pan over a tile that contains a pathological polygon, you add one more thread that burns CPU forever ( #305 ).
I wanted to reclaim this accumulated garbage without losing the session or the spot I was currently looking at.…