Using dup2 for piping

后端 未结 2 1902
执笔经年
执笔经年 2020-12-02 12:50

How do I use dup2 to perform the following command?

ls -al | grep alpha | more
2条回答
  •  佛祖请我去吃肉
    2020-12-02 13:14

    You would use pipe(2,3p) as well. Create the pipe, fork, duplicate the appropriate end of the pipe onto FD 0 or FD 1 of the child, then exec.

提交回复
热议问题