1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)f77_abort.c	5.2.1 (2.11BSD)	1999/10/24
   7:  *
   8:  *	all f77 aborts eventually call f77_abort.
   9:  *	f77_abort cleans up open files and terminates with a dump if needed,
  10:  *	with a message otherwise.
  11:  *
  12:  */
  13: 
  14: #include <signal.h>
  15: #include "fio.h"
  16: 
  17: #ifndef pdp11
  18: char *getenv();
  19: int _lg_flag;   /* _lg_flag is non-zero if -lg was specified to ld */
  20: #endif
  21: 
  22: f77_abort( nargs, err_val, act_core )
  23: {
  24:     int core_dump;
  25:     sigset_t set;
  26: #ifndef pdp11
  27:     /*
  28: 	 * The f77_dump_flag is really unnecessary to begin with and not
  29: 	 * implementing it on the PDP-11 saves a little space ...
  30: 	 */
  31:     char first_char, *env_var;
  32: 
  33:     env_var = getenv("f77_dump_flag");
  34:     first_char = (env_var == NULL) ? 0 : *env_var;
  35: #endif
  36: 
  37:     signal(SIGILL, SIG_DFL);
  38:     (void)sigemptyset(&set);
  39:     (void)sigaddset(&set, SIGILL);
  40:     (void)sigprocmask(SIG_UNBLOCK, &set, NULL); /* don't block */
  41: 
  42: #ifdef pdp11
  43:     /*
  44: 	 * See if we want a core dump:  don't dump for signals like hangup.
  45: 	 */
  46:     core_dump = (nargs != 2) || act_core;
  47: #else
  48:     /* see if we want a core dump:
  49: 		first line checks for signals like hangup - don't dump then.
  50: 		second line checks if -lg specified to ld (e.g. by saying
  51: 			-g to f77) and checks the f77_dump_flag var. */
  52:     core_dump = ((nargs != 2) || act_core) &&
  53:         ( (_lg_flag && (first_char != 'n')) || first_char == 'y');
  54: #endif
  55: 
  56:     if( !core_dump )
  57:         fprintf(units[STDERR].ufd,"*** Execution terminated\n");
  58: 
  59:     f_exit();
  60:     _cleanup();
  61:     if( nargs ) errno = err_val;
  62:     else errno = -2;   /* prior value will be meaningless,
  63: 				so set it to undefined value */
  64: 
  65:     if( core_dump ) abort();
  66:     else  exit( errno );
  67: }
Last modified: 1999-10-24
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2563
Valid CSS Valid XHTML 1.0 Strict