Annotation of 42BSD/ucb/pascal/utilities/pix.c, revision 1.1.1.1

1.1       root        1: /* Copyright (c) 1979 Regents of the University of California */
                      2: 
                      3: static char sccsid[] = "@(#)pix.c 1.4 1/22/83";
                      4: 
                      5: /*
                      6:  * pix - pi then px
                      7:  *
                      8:  * Bill Joy UCB August 26, 1977
                      9:  */
                     10: 
                     11: #include "whoami.h"
                     12: #include "objfmt.h"
                     13: #include "config.h"
                     14: #define        ERRS    1
                     15: 
                     16: char   *name;
                     17: 
                     18: int    onintr();
                     19: 
                     20: #define        ETXTBSY 26
                     21: 
                     22: main(argc, argv)
                     23:        int argc;
                     24:        char *argv[];
                     25: {
                     26:        register char **av;
                     27:        register int ac;
                     28:        int i, io, pid, status;
                     29:        extern errno;
                     30: 
                     31:        do
                     32:                io = open("/dev/null", 0);
                     33:        while (io >= 0 && io < 3);
                     34:        for (io = 3; io < 15; io++)
                     35:                close(io);
                     36:        if ((signal(2, 1) & 01) == 0)
                     37:                signal(2, onintr);
                     38:        for (ac = 1; ac < argc; ac++)
                     39:                if (dotted(argv[ac], 'p')) {
                     40:                        ac++;
                     41:                        break;
                     42:                }
                     43:        name = "-o/tmp/pixaXXXXX" + 2;
                     44:        mktemp(name);
                     45:        for (;;) {
                     46:                io = creat(name, 0400);
                     47:                if (io > 0)
                     48:                        break;
                     49:                if (name[8] == 'z') {
                     50:                        perror(name);
                     51:                        exit(1);
                     52:                }
                     53:                name[8]++;
                     54:        }
                     55:        pid = fork();
                     56:        if (pid == -1) {
                     57:                write(2, "No more processes\n", 18);
                     58:                onintr();
                     59:        }
                     60:        if (pid == 0) {
                     61:                if (io != 3) {
                     62:                        write(2, "Impossible error in pix\n", 24);
                     63:                        onintr();
                     64:                }
                     65:                argv[ac] = 0;
                     66:                argv[0] = name - 2;
                     67:                do
                     68:                        execv(pi_comp, argv);
                     69:                while (errno == ETXTBSY);
                     70:                write(2, "Can't find pi\n", 14);
                     71:                onintr();
                     72:        }
                     73:        close(io);
                     74:        do
                     75:                i = wait(&status);
                     76:        while (i != pid && i != -1);
                     77:        if (i == -1 || (status & 0377))
                     78:                onintr();
                     79:        if (status != 0) {
                     80:                if ((status >> 8) == ERRS)
                     81:                        write(2, "Execution suppressed due to compilation errors\n", 47);
                     82:                onintr();
                     83:        }
                     84:        ac--;
                     85:        argv[ac] = name;
                     86:        ac--;
                     87:        argv[ac] = "pix";
                     88:        argv[argc] = 0;
                     89:        do
                     90:                execv(px_debug, &argv[ac]);
                     91:        while (errno == ETXTBSY);
                     92:        write(2, "Can't find px\n", 14);
                     93:        onintr();
                     94: }
                     95: 
                     96: dotted(cp, ch)
                     97:        char *cp, ch;
                     98: {
                     99:        register int i;
                    100: 
                    101:        i = strlen(cp);
                    102:        return (i > 1 && cp[i - 2] == '.' && cp[i - 1] == ch);
                    103: }
                    104: 
                    105: onintr()
                    106: {
                    107: 
                    108:        signal(2, 1);
                    109:        unlink(name);
                    110:        exit(1);
                    111: }

unix.superglobalmegacorp.com

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