This is a really great explanation. I believe that libdill [1] [2] [3] works this way but this gave me a much more thorough understanding.
[1] http://libdill.org/ [2] Call to setjmp: https://github.com/sustrik/libdill/blob/de7a917bc39756f61237... [3] Call to longjmp: https://github.com/sustrik/libdill/blob/de7a917bc39756f61237...