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

Defined functions

dotted defined in line 83; used 4 times
main defined in line 14; never used
onintr defined in line 92; used 8 times

Defined variables

name defined in line 10; used 9 times

Defined macros

ERRS defined in line 8; used 1 times
  • in line 70
Last modified: 1983-03-13
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 805
Valid CSS Valid XHTML 1.0 Strict