C
#include <setjmp.h>
int main(void)
{
jmp_buf jb;
setjmp(jb);
write(1, "hi\n", 3);
longjmp( jb, 1 );
return 0;
}
setjmp/longjmp are library functions that do evil, typically used for exception handling. The longjmp will go to wherever the setjmp was called, which can be in higher stack frames.
To limit, keep a counter and do the longjmp conditionally, eg
if( cnt++ < LIMIT )
longjmp( jb, 1 );