The sentinel-marker trick is solid but there's a real gotcha waiting in it: if stdout and stderr aren't merged, the marker on stdout can show up before stderr has actually flushed, especially once a command spawns something with its own buffering. We hit almost this exact bug in a similar persistent-shell harness — the loop moved on thinking a command had succeeded while an error was still landing on stderr a beat later, and it took a while to notice because nothing looked wrong until much further downstream. Worth checking whether Sadhan reads both streams as one before trusting the marker, or that class of false-positive will show up eventually on a command that writes to both.