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

Original: https://www.cnblogs.com/thotf/p/16255565.html
Author: thotf
Title: lab 1

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/582274/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球