Annotation of 42BSD/usr.lib/libF77/main.c, revision 1.1.1.1

1.1       root        1: /* STARTUP PROCEDURE FOR UNIX FORTRAN PROGRAMS */
                      2: char id_libF77[] = "@(#)main.c 2.15    8/25/83";
                      3: 
                      4: #include <stdio.h>
                      5: #include <signal.h>
                      6: #include "../libI77/fiodefs.h"
                      7: 
                      8: int xargc;
                      9: char **xargv;
                     10: 
                     11: main(argc, argv, arge)
                     12: int argc;
                     13: char **argv;
                     14: char **arge;
                     15: {
                     16: int sigdie();
                     17: long int (*sigf)();
                     18: int signum;
                     19: 
                     20: xargc = argc;
                     21: xargv = argv;
                     22: 
                     23: for (signum=1; signum<=16; signum++)
                     24: {
                     25:        if((sigf=signal(signum, sigdie)) != SIG_DFL) signal(signum, sigf);
                     26: }
                     27: 
                     28: #ifdef pdp11
                     29:        ldfps(01200); /* detect overflow as an exception */
                     30: #endif
                     31: 
                     32: f_init();
                     33: MAIN_();
                     34: f_exit();
                     35: }
                     36: 
                     37: struct action {
                     38:        char *mesg;
                     39:        int   core;
                     40: } sig_act[16] = {
                     41:        {"Hangup", 0},                  /* SIGHUP  */
                     42:        {"Interrupt!", 0},              /* SIGINT  */
                     43:        {"Quit!", 1},                   /* SIGQUIT */
                     44:        {"Illegal ", 1},                /* SIGILL  */
                     45:        {"Trace Trap", 1},              /* SIGTRAP */
                     46:        {"IOT Trap", 1},                /* SIGIOT  */
                     47:        {"EMT Trap", 1},                /* SIGEMT  */
                     48:        {"Arithmetic Exception", 1},    /* SIGFPE  */
                     49:        { 0, 0},                        /* SIGKILL */
                     50:        {"Bus error", 1},               /* SIGBUS  */
                     51:        {"Segmentation violation", 1},  /* SIGSEGV */
                     52:        {"Sys arg", 1},                 /* SIGSYS  */
                     53:        {"Open pipe", 0},               /* SIGPIPE */
                     54:        {"Alarm", 0},                   /* SIGALRM */
                     55:        {"Terminated", 0},              /* SIGTERM */
                     56:        {"Sig 16", 0},                  /* unassigned */
                     57: };
                     58: 
                     59: struct action act_fpe[] = {
                     60:        {"Integer overflow", 1},
                     61:        {"Integer divide by 0", 1},
                     62:        {"Floating point overflow trap", 1},
                     63:        {"Floating divide by zero trap", 1},
                     64:        {"Floating point underflow trap", 1},
                     65:        {"Decimal overflow", 1},
                     66:        {"Subscript range", 1},
                     67:        {"Floating point overflow", 0},
                     68:        {"Floating divide by zero", 0},
                     69:        {"Floating point underflow", 0},
                     70: };
                     71: 
                     72: struct action act_ill[] = {
                     73:        {"addr mode", 1},
                     74:        {"instruction", 1},
                     75:        {"operand", 0},
                     76: };
                     77: 
                     78: #if    vax
                     79: sigdie(s, t, sc)
                     80: int s; int t; struct sigcontext *sc;
                     81: 
                     82: #else  pdp11
                     83: sigdie(s, t, pc)
                     84: int s; int t; long pc;
                     85: 
                     86: #endif
                     87: {
                     88: extern unit units[];
                     89: register struct action *act = &sig_act[s-1];
                     90: /* print error message, then flush buffers */
                     91: 
                     92: if (s == SIGHUP || s == SIGINT || s == SIGQUIT)
                     93:        signal(s, SIG_IGN);     /* don't allow it again */
                     94: else
                     95:        signal(s, SIG_DFL);     /* shouldn't happen again, but ... */
                     96: 
                     97: #if    vax
                     98: sigsetmask(0);                 /* don't block */
                     99: #endif
                    100: 
                    101: if (act->mesg)
                    102:        {
                    103:        fprintf(units[STDERR].ufd, "*** %s", act->mesg);
                    104:        if (s == SIGFPE)
                    105:                {
                    106:                if (t >= 1 && t <= 10)
                    107:                        fprintf(units[STDERR].ufd, ": %s", act_fpe[t-1].mesg);
                    108:                else
                    109:                        fprintf(units[STDERR].ufd, ": Type=%d?", t);
                    110:                }
                    111:        else if (s == SIGILL)
                    112:                {
                    113:                if (t == 4) t = 2;      /* 4.0bsd botch */
                    114:                if (t >= 0 && t <= 2)
                    115:                        fprintf(units[STDERR].ufd, "%s", act_ill[t].mesg);
                    116:                else
                    117:                        fprintf(units[STDERR].ufd, "compat mode: Code=%d", t);
                    118:                }
                    119:        putc('\n', units[STDERR].ufd);
                    120:        }
                    121: f_exit();
                    122: _cleanup();
                    123: 
                    124: if(act->core)
                    125:        {
                    126:        /* now get a core */
                    127: #if    vax
                    128:        signal(SIGILL, SIG_DFL);
                    129: #else  pdp11
                    130:        signal(SIGIOT, SIG_DFL);
                    131: #endif
                    132:        abort();
                    133:        }
                    134: exit(s);
                    135: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.