06-23-2008
Go Global
Either make those global variables or use the setjmp() and longjmp() calls. Caveat with setjmp() and longjmp() is that only one of the local variables of main() either a, b, or c can be changed by func() not all of them. To change all of them declare them as globals.
6 More Discussions You Might Find Interesting
1. Solaris
How can I make analysis for catalina.out (2 Replies)
Discussion started by: Burhan
2 Replies
2. Programming
helo can u tell me what do you mean by stack winding and stack unwinding
Regards,
Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies
3. Shell Programming and Scripting
:confused:Hi ,
Can someone please advise what is the meaning of metacharacters in below code?
a_PROCESS=${0##*/}
a_DPFX=${a_PROCESS%.*}
a_LPFX="a_DPFX : $$ : "
a_UPFX="Usage: $a_PROCESS"
Regards,
gehlnar (3 Replies)
Discussion started by: gehlnar
3 Replies
4. UNIX for Dummies Questions & Answers
Hey Guys,
Does anyone know how to count the separate amount of words in a text file?
e.g
the 5
and 20
Furthermore does anyone know how to convert whole numbers in decimals?
Thanks (24 Replies)
Discussion started by: John0101
24 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I am new to the linux kernel development area. I want to know what is the difference between kernel mode stack and user mode stack? Does each process has a user mode stack and a kernel mode stack?? Or Each process has a user mode stack and there is only one kernel mode stack that is shared by... (4 Replies)
Discussion started by: saurabhkoar
4 Replies
6. Infrastructure Monitoring
Dear All,
I am an performance tester. Now i am working in project where we are using linux 2.6.32. Now I got an oppurtunity to learn the monitoring the server. As part of this task i need to do analysis of the Nmon report. I was completely blank in this.
So please suggest me how to start... (0 Replies)
Discussion started by: iamsengu
0 Replies
LEARN ABOUT ULTRIX
setjmp
setjmp(3) Library Functions Manual setjmp(3)
Name
setjmp, longjmp - non-local goto
Syntax
#include <setjmp.h>
int setjmp (env)
jmp_buf env;
void longjmp (env, val)
jmp_buf env;
int val;
Description
The and functions help deal with errors and interrupts encountered in a low-level subroutine of a program.
The function saves its stack environment in env (whose type, jmp_buf, is defined in the <setjmp.h> header file) for later use by It returns
the value 0.
The function restores the environment saved by the last call of with the corresponding env argument. After finishes, program execution
continues as if the corresponding call of (which must not itself have returned in the interim) had just returned the value val. The func-
tion cannot cause to return the value 0. If is invoked with a second argument of 0, returns 1. At the time of the second return from all
accessible data have values as of the time is called. However, global variables have the expected values. For example, those as of the
time of the
Examples
#include <setjmp.h>
jmp_buf env;
int i = 0;
main ()
{
void exit();
if(setjmp(env) != 0) {
(void) printf("value of i on 2nd return from setjmp: %d0, i);
exit(0);
}
(void) printf("value of i on 1st return from setjmp: %d0, i);
i = 1;
g();
/*NOTREACHED*/
}
g()
{
longjmp(env, 1);
/*NOTREACHED*/
}
If the a.out resulting from this C language code is run, the output is as follows:
value of i on 1st return from setjmp:0
value of i on 2nd return from setjmp:1
Unexpected behavior occurs if is called without a previous call to or when the last such call was in a function which has since returned.
Restrictions
The values of the registers on the second return from are register values at the time of the first call to not those of the Thus, variables
in a given function can produce unexpected results in the presence of depending on whether they are register or stack variables.
See Also
signal(2).
RISC setjmp(3)