home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / internal / 2101 < prev    next >
Encoding:
Text File  |  1993-01-10  |  1008 b   |  39 lines

  1. Newsgroups: comp.unix.internals
  2. Path: sparky!uunet!sequent!muncher.sequent.com!washer
  3. From: washer@sequent.com (Jim "Throw it over the wall" Washer)
  4. Subject: Re: Question about longjmp () 
  5. Message-ID: <1993Jan10.145640.3647@sequent.com>
  6. Sender: usenet@sequent.com (usenet )
  7. Nntp-Posting-Host: crg8.sequent.com
  8. Organization: Sequent Computer Systems, Inc.
  9. References: <C0JpMo.1rGr@austin.ibm.com>
  10. Date: Sun, 10 Jan 93 14:56:40 GMT
  11. Lines: 26
  12.  
  13. In article <C0JpMo.1rGr@austin.ibm.com> subra@bynar.austin.ibm.com (Sivarama Subramanian) writes:
  14. >Hi folks,
  15. >    I have the following code segment.
  16. >    main ()
  17. >    {
  18. >        int i = 0;
  19. >        jmp_buf buf;
  20. >        setjmp (buf);
  21. >        printf ("%d\n", i);
  22. >        if ( i == 1 )
  23. >            exit;
  24. >        i = 1;
  25. >        longjmp (buf, 1);
  26. >    }
  27. >    My question is, should the value of i change or not.
  28. >
  29. >Thank you
  30. >
  31. >subra
  32. >
  33. Absolutely!. There is no magic with setjmp/longjmp.. It simply sets the pc
  34. and the stack pointer back to the setjmp call and returns again.. 'Both'
  35. intances of main share a common stack.
  36.  - jim
  37.  
  38.  
  39.