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) ; }

 

posted on 2022-05-10 21:49  thotf  阅读(7)  评论(0)    收藏  举报

导航