home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / cmd / learn / makpipe.c < prev    next >
Encoding:
C/C++ Source or Header  |  1979-01-10  |  321 b   |  21 lines

  1. #include "stdio.h"
  2.  
  3. makpipe()
  4. {
  5.     int f[2];
  6.  
  7.     pipe(f);
  8.     if (fork()==0) {
  9.         close(f[1]);
  10.         close(0);
  11.         dup(f[0]);
  12.         close(f[0]);
  13.         execl ("/bin/sh", "sh", "-i", 0);
  14.         execl ("/usr/bin/sh", "sh", "-i", 0);
  15.         write(2,"Exec error\n",11);
  16.     }
  17.     close(f[0]);
  18.     sleep(2);    /* so shell won't eat up too much input */
  19.     return(f[1]);
  20. }
  21.