1: #include "hd.h"
   2: #include "command.h"
   3: 
   4: /* Interface to make.  Fmake forks make off and returns.  Wmake waits
   5:    for completion.  Both cause output to be saved in the file .makerror.
   6: */
   7: fmake () {
   8: 
   9:     int p;          /*	Process number */
  10:     int mfile;      /*	File number of .makerror */
  11:     FILE *mstream;      /*	Stream of .makerror */
  12:     FILE *showopen ();  /*	Opener of mstream */
  13: 
  14:     mstream = showopen ("w", MAKEMODE);
  15:     if (mstream == NULL) return NOREPLOT;
  16:     mfile = fileno (mstream);
  17: 
  18:     if (myfork () == 0) {
  19:         if ((p = myfork ()) == 0) {
  20:             close (outfile);  close (errorfile);
  21:             dup (mfile);  dup (mfile);
  22:             close (infile);  open ("/dev/null", 0);
  23: 
  24:             myexecl (MAKE, MAKE, 0);
  25:         } else {
  26:             join (p);
  27:             beep (); sleep (2); beep ();
  28:             exit (0);
  29:         }
  30:     } else {
  31:         fclose (mstream);
  32:         putmsg (MAKE);
  33:     }
  34:     return NOREPLOT;
  35: }
  36: 
  37: wmake () {
  38: 
  39:     int p;          /*	Process number */
  40:     FILE *mstream;      /*	Stream of .makerror */
  41:     FILE *showopen ();  /*	Opener of mstream */
  42:     register ch;        /*	Work character */
  43: 
  44:     int pipefile [2];   /*	Pipe file numbers */
  45: #	define pipein pipefile [0]
  46: #	define pipeout    pipefile [1]
  47: 
  48:     FILE *pipestrm;     /*	Stream of pipein */
  49: 
  50:     mstream = showopen ("w", MAKEMODE);
  51:     if (mstream == NULL) return NOREPLOT;
  52: 
  53:     tty_push (COOKEDMODE);
  54:     pipe (pipefile);
  55:     if ((p = myfork ()) == 0) {
  56:         close (outfile);  close (errorfile);
  57:         dup (pipeout);  dup (pipeout);
  58:         myexecl (MAKE, MAKE, 0);
  59:     } else {
  60:         close (pipeout);
  61:         pipestrm = fdopen (pipein, "r");
  62:         while ((ch = getc (pipestrm)) != EOF) {
  63:             putchar (ch);  putc (ch, mstream);
  64:         }
  65:         fclose (pipestrm);  fclose (mstream);
  66:         join (p);
  67:     }
  68:     tty_pop ();
  69:     return CMD_SE | REPLOT;
  70: }

Defined functions

fmake defined in line 7; used 3 times
wmake defined in line 37; used 6 times

Defined macros

pipein defined in line 45; used 1 times
  • in line 61
pipeout defined in line 46; used 3 times
Last modified: 1980-08-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 720
Valid CSS Valid XHTML 1.0 Strict