A
aleksa
static jmp_buf environment;
void testproc (void)
{
longjmp(environment, 1);
}
long do_setjmp (void)
{
return setjmp(environment);
}
long testing (void)
{
long status;
status = setjmp(environment);
// status = do_setjmp();
if (status == 0) {
testproc();
return -1;
}
return status;
}
Prog starts in 'testing', calls setjmp then calls testproc which calls
longjmp.
Now, if I call setjmp from 'testing', it works. First time, returned
status is zero,
so testproc gets called, second time is 1, so I return the status(1).
But, if I call setjmp with do_setjmp, when I call testproc and it
calls longjmp,
longjmp does return where it is supposed to (in do_setjmp) but
do_setjmp
then returns to 'return -1;', i.e. after a call to testproc, and not
to 'if (status == 0)'.
Why?
Cheers,
Aleksandar
void testproc (void)
{
longjmp(environment, 1);
}
long do_setjmp (void)
{
return setjmp(environment);
}
long testing (void)
{
long status;
status = setjmp(environment);
// status = do_setjmp();
if (status == 0) {
testproc();
return -1;
}
return status;
}
Prog starts in 'testing', calls setjmp then calls testproc which calls
longjmp.
Now, if I call setjmp from 'testing', it works. First time, returned
status is zero,
so testproc gets called, second time is 1, so I return the status(1).
But, if I call setjmp with do_setjmp, when I call testproc and it
calls longjmp,
longjmp does return where it is supposed to (in do_setjmp) but
do_setjmp
then returns to 'return -1;', i.e. after a call to testproc, and not
to 'if (status == 0)'.
Why?
Cheers,
Aleksandar