其他分享
首页 > 其他分享> > lab 1

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

 

标签:int,father,lab,son,dup,close,buf
来源: https://www.cnblogs.com/thotf/p/16255565.html