Annotation of 42BSD/ingres/source/monitor/quit.c, revision 1.1.1.1

1.1       root        1: # include      "monitor.h"
                      2: # include      <ingres.h>
                      3: # include      <aux.h>
                      4: # include      <sccs.h>
                      5: # include      <signal.h>
                      6: 
                      7: SCCSID(@(#)quit.c      7.2     7/6/83)
                      8: 
                      9: 
                     10: 
                     11: /*
                     12: **  QUIT INGRES
                     13: **
                     14: **     This routine starts the death of the other processes.  It
                     15: **     then prints out the logout message, and then waits for the
                     16: **     rest of the system to die.  Note, however, that no relations
                     17: **     are removed; this must be done using the PURGE command.
                     18: **
                     19: **     Trace Flags:
                     20: **             35
                     21: */
                     22: 
                     23: /* list of fatal signals */
                     24: char   *Siglist[] =
                     25: {
                     26:        "Signal 0",
                     27:        "hangup",
                     28:        "interrupt",
                     29:        "quit",
                     30:        "illegal instruction",
                     31:        "trace trap",
                     32:        "IOT",
                     33:        "EMT",
                     34:        "floating point exception",
                     35:        "killed",
                     36:        "bus error",
                     37:        "segmentation violation",
                     38:        "bad system call",
                     39:        "broken pipe",
                     40:        "alarm",
                     41: };
                     42: 
                     43: quit()
                     44: {
                     45:        register int    ndx;
                     46:        register int    pidptr;
                     47:        register int    err;
                     48:        char            buf[100];
                     49:        int             status;
                     50:        int             pidlist[50];
                     51:        extern int      (*ExitFn)();
                     52:        extern          exit();
                     53:        extern int      sys_nerr;
                     54:        extern char     *sys_errlist[];
                     55:        char            indexx[0400];
                     56:        extern char     SysIdent[];
                     57: 
                     58: #      ifdef xMTR1
                     59:        if (tTf(35, -1))
                     60:                printf("entered quit\n");
                     61: #      endif
                     62: 
                     63:        /* INTERCEPT ALL FURTHER INTERRUPTS */
                     64:        signal(SIGINT, SIG_IGN);
                     65:        signal(SIGQUIT, SIG_IGN);
                     66:        ExitFn = exit;
                     67: 
                     68:        cm_close();
                     69: 
                     70: #      ifdef xMTR3
                     71:        if (tTf(35, 2))
                     72:                printf("unlinking %s\n", Qbname);
                     73: #      endif
                     74: 
                     75:        /* REMOVE THE QUERY-BUFFER FILE */
                     76:        fclose(Qryiop);
                     77:        unlink(Qbname);
                     78:        if (Trapfile != NULL)
                     79:                fclose(Trapfile);
                     80:        pidptr = 0;
                     81:        err = 0;
                     82: 
                     83:        /* clear out the system error index table */
                     84:        for (ndx = 0; ndx < 0400; ndx++)
                     85:                indexx[ndx] = 0;
                     86: 
                     87:        /* wait for all process to terminate */
                     88:        while ((ndx = wait(&status)) != -1)
                     89:        {
                     90: #              ifdef xMTR2
                     91:                if (tTf(35, 5))
                     92:                        printf("quit: pid %u: %d/%d\n",
                     93:                                ndx, status >> 8, status & 0177);
                     94: #              endif
                     95:                pidlist[pidptr++] = ndx;
                     96:                if ((status & 0177) != 0)
                     97:                {
                     98:                        printf("%d: ", ndx);
                     99:                        ndx = status & 0177;
                    100:                        if (ndx > sizeof Siglist / sizeof Siglist[0])
                    101:                                printf("Abnormal Termination %d", ndx);
                    102:                        else
                    103:                                printf("%s", Siglist[ndx]);
                    104:                        if ((status & 0200) != 0)
                    105:                                printf(" -- Core Dumped");
                    106:                        printf("\n");
                    107:                        err++;
                    108:                        indexx[0377 - ndx]++;
                    109:                }
                    110:                else
                    111:                {
                    112:                        indexx[(status >> 8) & 0377]++;
                    113:                }
                    114:        }
                    115:        if (err)
                    116:        {
                    117:                printf("pid list:");
                    118:                for (ndx = 0; ndx < pidptr; ndx++)
                    119:                        printf(" %u", pidlist[ndx]);
                    120:                printf("\n");
                    121:        }
                    122: 
                    123:        /* print index of system errors */
                    124:        err = 0;
                    125:        for (ndx = 1; ndx <= 0377; ndx++)
                    126:        {
                    127:                if (indexx[ndx] == 0)
                    128:                        continue;
                    129:                if (ndx <= sys_nerr)
                    130:                {
                    131:                        if (err == 0)
                    132:                                printf("\nUNIX error dictionary:\n");
                    133:                        printf("%3d: %s\n", ndx, sys_errlist[ndx]);
                    134:                }
                    135:                if (err == 0)
                    136:                        err = ndx;
                    137:        }
                    138:        if (err > 0 && err <= sys_nerr)
                    139:                printf("\n");
                    140: 
                    141:        /* PRINT LOGOUT CUE ? */
                    142:        if (Nodayfile >= 0)
                    143:        {
                    144:                time(buf);
                    145:                printf("%s logout\n%s", SysIdent, ctime(buf));
                    146:                if (getuser(Usercode, buf) == 0)
                    147:                {
                    148:                        for (ndx = 0; buf[ndx]; ndx++)
                    149:                                if (buf[ndx] == ':')
                    150:                                        break;
                    151:                        buf[ndx] = 0;
                    152:                        printf("goodbye %s ", buf);
                    153:                }
                    154:                else
                    155:                        printf("goodbye ");
                    156:                printf("-- come again\n");
                    157:        }
                    158: #      ifdef xMTR1
                    159:        if (tTf(35, 3))
                    160:                printf("quit: exit(%d)\n", err);
                    161: #      endif
                    162:        exit(err);
                    163: }

unix.superglobalmegacorp.com

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