Annotation of researchv9/cmd/sh/error.c, revision 1.1

1.1     ! root        1: /*     @(#)error.c     1.4     */
        !             2: /*
        !             3:  * UNIX shell
        !             4:  *
        !             5:  * Bell Telephone Laboratories
        !             6:  *
        !             7:  */
        !             8: 
        !             9: #include       "defs.h"
        !            10: 
        !            11: 
        !            12: /* ========    error handling  ======== */
        !            13: 
        !            14: failed(s1, s2)
        !            15: char   *s1, *s2;
        !            16: {
        !            17:        prp();
        !            18:        prs_cntl(s1);
        !            19:        if (s2)
        !            20:        {
        !            21:                prs(colon);
        !            22:                prs(s2);
        !            23:        }
        !            24:        newline();
        !            25:        exitsh(ERROR);
        !            26: }
        !            27: 
        !            28: error(s)
        !            29: char   *s;
        !            30: {
        !            31:        failed(s, NIL);
        !            32: }
        !            33: 
        !            34: exitsh(xno)
        !            35: int    xno;
        !            36: {
        !            37:        /*
        !            38:         * Arrive here from `FATAL' errors
        !            39:         *  a) exit command,
        !            40:         *  b) default trap,
        !            41:         *  c) fault with no trap set.
        !            42:         *
        !            43:         * Action is to return to command level or exit.
        !            44:         */
        !            45:        exitval = xno;
        !            46:        flags |= eflag;
        !            47:        if ((flags & (forked | errflg | ttyflg)) != ttyflg)
        !            48:                done();
        !            49:        else
        !            50:        {
        !            51:                clearup();
        !            52:                restore(0);
        !            53:                clear_buff();
        !            54:                execbrk = breakcnt = funcnt = 0;
        !            55:                longjmp(errshell, 1);
        !            56:        }
        !            57: }
        !            58: 
        !            59: done()
        !            60: {
        !            61:        register char   *t;
        !            62: 
        !            63:        if (t = trapcom[0])
        !            64:        {
        !            65:                trapcom[0] = 0;
        !            66:                execexp(t, 0);
        !            67:                shfree(t);
        !            68:        }
        !            69:        else
        !            70:                chktrap();
        !            71: 
        !            72:        rmtemp(0);
        !            73:        rmfunctmp();
        !            74: 
        !            75: #ifdef ACCT
        !            76:        doacct();
        !            77: #endif
        !            78:        exit(exitval);
        !            79: }
        !            80: 
        !            81: rmtemp(base)
        !            82: struct ionod   *base;
        !            83: {
        !            84:        while (iotemp > base)
        !            85:        {
        !            86:                unlink(iotemp->ioname);
        !            87:                shfree(iotemp->iolink);
        !            88:                iotemp = iotemp->iolst;
        !            89:        }
        !            90: }
        !            91: 
        !            92: rmfunctmp()
        !            93: {
        !            94:        while (fiotemp)
        !            95:        {
        !            96:                unlink(fiotemp->ioname);
        !            97:                fiotemp = fiotemp->iolst;
        !            98:        }
        !            99: }

unix.superglobalmegacorp.com

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