longjmp -- Perform Nonlocal goto

SYNOPSIS

 #include <setjmp.h>

 void longjmp(jmp_buf env, int code);
 

DESCRIPTION

longjmp returns control to an ancestor routine, passing the value of the integer code. The point of return is determined by the contents of env, which should be initialized by a call to setjmp in the target routine. Note that if the value of code is 0, the value returned to the target is 1.

RETURN VALUE

Control does not return from longjmp.

CAUTION

longjmp does not change the program's signal mask. Use sigsetjmp to save the signal mask, and siglongjmp to restore the signal mask to the mask in effect when sigsetjmp was called.

ERRORS

If the target is not valid (that is, if the routine that called setjmp has terminated), a user ABEND 1204 is issued. If an invalid env is not detected, serious (and unpredictable) problems occur.

If you attempt to terminate a routine in a language other than C, a user ABEND 1224 is issued. See Appendix 5, "Using the INDep Option for Interlanguage Communication," in the SAS/C Compiler and Library User's Guide, Fourth Edition for more information.

EXAMPLE

  #include <stdio.h>
  #include <setjmp.h>
  #include <stdlib.h>

  jmp_buf env;

  main()
  {
     int ret;

     if ((ret = setjmp(env)) != 0) {
        fprintf(stderr, "longjmp called with value %dn", ret);
        exit(1);
     }
     dummy();
     fprintf(stderr, "longjmp was not called.n");
  }

  void dummy(void)
  {
     puts("Entering dummy routine.");
     longjmp(env, 3);
     puts("Never reached.");
  }

 

RELATED FUNCTIONS

blkjmp, setjmp, siglongjmp

SEE ALSO

Program Control Functions

Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.