lab 1

2022/5/10 23:01:05

本文主要是介绍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)    ;
    }

 



这篇关于lab 1的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程