I wanted to see the command without "messing" with the execution in any way - after all, it was running fine for 6 months, why interrupt it (and face potential effort in fixing messed up state) if I could see the command "from the outside"?
And that I did :-)
If you're worried about timing out of the process being unresponsive, just C-z and then "bg" real quick. Then you can up arrow at your leisure and "fg" when you've copied the command away...
Apparently C-z followed by fg is not bulletproof...
zsh does the right thing, when you bg it back it recovers the loop as it was. Bash seems to forget about the loop and only recovers the "sleep 1", when it starts executing again it sleeps 1 and exits.
If you want to make sure it will work you should wrap it around another bash:
bash -c 'while true ; do sleep 1 ; done'
should work fine. (while true ; do sleep 1 ; done)sleep(1) is the only process that can be suspended in this command. When you "fg", the suspended sleep(1) is signaled, and resumes. And then it exits.
When you do this in a subshell (in parens), you suspend/resume the subshell in its entirety, which capture the loop construct.
Why does it work in zsh?!
――――――