/* STARTUP PROCEDURE FOR UNIX FORTRAN PROGRAMS */
char id_libF77
[] = "@(#)main.c 2.17 %G%";
#include "../libI77/fiodefs.h"
for (signum
=1; signum
<=16; signum
++)
if((sigf
=signal(signum
, sigdie
)) != SIG_DFL
) signal(signum
, sigf
);
ldfps(01200); /* detect overflow as an exception */
{"Hangup", 0}, /* SIGHUP */
{"Interrupt!", 0}, /* SIGINT */
{"Quit!", 1}, /* SIGQUIT */
{"Illegal ", 1}, /* SIGILL */
{"Trace Trap", 1}, /* SIGTRAP */
{"IOT Trap", 1}, /* SIGIOT */
{"EMT Trap", 1}, /* SIGEMT */
{"Arithmetic Exception", 1}, /* SIGFPE */
{"Bus error", 1}, /* SIGBUS */
{"Segmentation violation", 1}, /* SIGSEGV */
{"Sys arg", 1}, /* SIGSYS */
{"Open pipe", 0}, /* SIGPIPE */
{"Alarm", 0}, /* SIGALRM */
{"Terminated", 0}, /* SIGTERM */
{"Sig 16", 0}, /* unassigned */
struct action act_fpe
[] = {
{"Integer divide by 0", 1},
{"Floating point overflow trap", 1},
{"Floating divide by zero trap", 1},
{"Floating point underflow trap", 1},
{"Floating point overflow", 0},
{"Floating divide by zero", 0},
{"Floating point underflow", 0},
struct action act_ill
[] = {
int s
; int t
; struct sigcontext
*sc
;
register struct action
*act
= &sig_act
[s
-1];
/* print error message, then flush buffers */
if (s
== SIGHUP
|| s
== SIGINT
|| s
== SIGQUIT
)
signal(s
, SIG_IGN
); /* don't allow it again */
signal(s
, SIG_DFL
); /* shouldn't happen again, but ... */
fprintf(units
[STDERR
].ufd
, "*** %s", act
->mesg
);
fprintf(units
[STDERR
].ufd
, ": %s", act_fpe
[t
-1].mesg
);
fprintf(units
[STDERR
].ufd
, ": Type=%d?", t
);
if (t
== 4) t
= 2; /* 4.0bsd botch */
fprintf(units
[STDERR
].ufd
, "%s", act_ill
[t
].mesg
);
fprintf(units
[STDERR
].ufd
, "compat mode: Code=%d", t
);
putc('\n', units
[STDERR
].ufd
);
f77_abort( s
, act
->core
);
extern int _dbsubc
; /* dbsubc is non-zero if -lg was specified to ld */
f77_abort( err_val
, act_core
)
char first_char
, *env_var
;
env_var
= getenv("f77_dump_flag");
first_char
= (env_var
== NULL
) ? 0 : *env_var
;
sigsetmask(0); /* don't block */
/* see if we want a core dump:
first line checks for signals like hangup - don't dump then.
second line checks if -lg specified to ld (e.g. by saying
-g to f77) and checks the f77_dump_flag var. */
core_dump
= ((nargs() != 2) || act_core
) &&
( (_dbsubc
&& (first_char
!= 'n')) || first_char
== 'y');
fprintf(units
[STDERR
].ufd
,"*** Execution terminated\n");
if( nargs() ) errno
= err_val
;
else errno
= -2; /* prior value will be meaningless,
so set it to undefined value */