lab 1
int father[2],son[2]; int son[2]; if (fork() == 0) { int n; char buf[1]; close(0); dup(father[1]); close(1); dup(son[0]); for(;;) { read(0,buf,n); write(1,buf,1); } } else { int n ; char buf[1] = 'c'; close(1); dup(father[0]); close(0); dup(son[1]);
for{ ;; }{ write(1,buf,1); read(0,buf,n) ; }
浙公网安备 33010602011771号