Writing my own shell… stuck on pipes?

前端 未结 9 703
攒了一身酷
攒了一身酷 2020-12-30 03:41

For the past few days I have been attempting to write my own shell implementation but I seem to have gotten stuck on getting pipes to work properly. I am able to parse a li

9条回答
  •  情深已故
    2020-12-30 03:56

    You are connecting each program's input to its own output. You probably wanted to connect each program's output to the next one's input instead.

    Instead of going for the general case of n processes in a pipeline, you should start with a basis of two and expand from there. You'll gain a better understanding of the way the file descriptors are plugged into each other if you proceed by extending working code instead of shooting directly for the complex structure.

提交回复
热议问题