linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* help for using setjmp and longjmp functions
@ 2004-12-20  7:08 Jagadeesh Bhaskar P
  0 siblings, 0 replies; 2+ messages in thread
From: Jagadeesh Bhaskar P @ 2004-12-20  7:08 UTC (permalink / raw)
  To: Linux C Programming

Hi,
	I tried writing a simple program to findout usage of setjmp and
longjmp() functions. The program ran in an infinite loop showing some
warnings. What is the problem? Can someone help me depicting the
behaviour of the setjmp and longjmp functions

/******** beginning of code *************/

#include <setjmp.h>
jmp_buf jmpbuffer;

void bar(void)
{
	printf("inside bar\n");
	longjmp(jmpbuffer, 1);
}

void foo(void)
{
	printf("before calling bar()\n");
	bar();
	printf("after calling bar()\n");
}
int
main(void)
{
	printf("before calling foo()\n");
	if(setjmp(jmpbuffer)!=0)
		perror("error setting");
	foo();
	printf("after foo()\n");

	return 0;
}
/**************** end of code ***********/

Hoping for help

TIA..

-- 
With regards,

Jagadeesh Bhaskar P


^ permalink raw reply	[flat|nested] 2+ messages in thread
[parent not found: <50C05B7AA7D6924FB5E384EF14BC647B495EE4@inba1mx2.corp.emc.com>]

end of thread, other threads:[~2004-12-20  7:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-20  7:08 help for using setjmp and longjmp functions Jagadeesh Bhaskar P
     [not found] <50C05B7AA7D6924FB5E384EF14BC647B495EE4@inba1mx2.corp.emc.com>
2004-12-20  7:54 ` Jagadeesh Bhaskar P

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).