All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jagadeesh Bhaskar P <jbhaskar@hclinsys.com>
To: Honnavalli_Sreevathsa@emc.com
Cc: Linux C Programming <linux-c-programming@vger.kernel.org>
Subject: RE: help for using setjmp and longjmp functions
Date: Mon, 20 Dec 2004 13:24:54 +0530	[thread overview]
Message-ID: <1103529293.4005.5.camel@myLinux> (raw)
In-Reply-To: <50C05B7AA7D6924FB5E384EF14BC647B495EE4@inba1mx2.corp.emc.com>

Yes I got it.....Thanks
On Mon, 2004-12-20 at 13:15, Honnavalli_Sreevathsa@emc.com wrote:
> Try this modified code. Hope its self explanatory. (This program does not
> demonstrate the best usage of setjmp/longjmp anyway. But ok for
> understanding the usage)
> 
> 
> #include <setjmp.h>
> jmp_buf jmpbuffer;
> 
> void bar(void)
> {
>         sleep(1);
>         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))
>         {
>                 printf("returned back from longjmp\n");
>                 goto done;
>         }
>         foo();
> 
> done:
>         printf("after foo()\n");
>         printf("\n-------------------------------------\n");
> 
>         return 0;
> }
> 
> 
> 
> 
> 
> > -----Original Message-----
> > From: linux-c-programming-owner@vger.kernel.org 
> > [mailto:linux-c-programming-owner@vger.kernel.org] On Behalf 
> > Of Jagadeesh Bhaskar P
> > Sent: Monday, December 20, 2004 12:38 PM
> > To: Linux C Programming
> > Subject: help for using setjmp and longjmp functions
> > 
> > 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
> > 
> > -
> > To unsubscribe from this list: send the line "unsubscribe 
> > linux-c-programming" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
-- 
Jagadeesh Bhaskar P <jbhaskar@hclinsys.com>


       reply	other threads:[~2004-12-20  7:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <50C05B7AA7D6924FB5E384EF14BC647B495EE4@inba1mx2.corp.emc.com>
2004-12-20  7:54 ` Jagadeesh Bhaskar P [this message]
2004-12-20  7:08 help for using setjmp and longjmp functions Jagadeesh Bhaskar P

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1103529293.4005.5.camel@myLinux \
    --to=jbhaskar@hclinsys.com \
    --cc=Honnavalli_Sreevathsa@emc.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.