util  Diff

Differences From Artifact [d3537d80bd]:

To Artifact [882c831cca]:


   139    139   
   140    140   	// note ptys and pipes use basically the same
   141    141   	// interface; you can use one as a drop-in
   142    142   	// replacement for the other, tho the creation
   143    143   	// function syntax is a bit different.
   144    144   
   145    145   	if(fork()) goto master;
   146         -	      else goto child;
          146  +	      else goto slave;
   147    147   
   148    148   	master: {
   149    149   		close(wr);
   150    150   		char buf[256]; size_t sz;
   151    151   		while(sz = read(rd, buf, 255)) {
   152    152   			buf[sz]=0;
   153    153   			for (size_t i=0;i<sz;++i) {
................................................................................
   163    163   	}
   164    164   
   165    165   	leave: {
   166    166   		close(rd);
   167    167   		return 0;
   168    168   	}
   169    169   
   170         -	child: {
          170  +	slave: {
   171    171   		close(rd);
   172    172   		
   173    173   		// redirect stdout (NOT stderr) to our pty master
   174    174   		dup2(wr, 1);
   175    175   		close(wr);
   176    176   
   177    177   		execv(argv[1],argv+2);
   178    178   		return 1; // THIS SHOULD NEVER HAPPEN
   179    179   	}
   180    180   }