1: #
   2: /*  Curdir finds the name of the working directory and puts in
   3:     wdname.  This is done by calling on the pwd program.
   4: */
   5: #include "hd.h"
   6: #include "mydir.h"
   7: static char pwd[] = {"/bin/pwd"};
   8: 
   9: curdir () {
  10: 
  11: int p, rdlen, pipefile [2];
  12: #define pipein  pipefile [0]
  13: #define pipeout pipefile [1]
  14: 
  15: pipe (pipefile);
  16: printf ("%s\n", pwd);
  17: if ((p = myfork ()) == 0) {
  18:     close (outfile);  dup (pipeout);
  19:     close (pipein);  close (pipeout);
  20:     execl (pwd, pwd, 0);
  21:     exit (1);
  22: } else {
  23:     close (pipeout);
  24:     join (p);
  25:     rdlen = read (pipein, wdname, sizeof wdname);
  26:     if (rdlen < 2 || rdlen == sizeof wdname || wdname [0] != '/') {
  27:         printf ("Cannot find name of working directory\n\r");
  28:         return 1;
  29:     }
  30:     wdname [rdlen - 1] = 0;
  31:     close (pipein);
  32: }
  33: return 0;
  34: }

Defined functions

curdir defined in line 9; used 1 times

Defined variables

pwd defined in line 7; used 3 times

Defined macros

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