How to make this pipe work in c++?

后端 未结 3 595
长情又很酷
长情又很酷 2021-01-22 09:07

I am programming a shell in c++. It needs to be able to pipe the output from one thing to another. For example, in linux, you can pipe a textfile to more by doing cat tex

3条回答
  •  误落风尘
    2021-01-22 09:57

    fopen() is not used to create pipes. It can be used to open the file descriptor, but it is not necessary to do so.

    Pipes are created with the pipe(2) call, before forking off the process. The subprocess has a little bit of file descriptor management to do before execing the command. See the example in pipe's documentation.

提交回复
热议问题