在C Shell中实现管道

我是编程的新手,正在C外壳中实现管道。

我发现一些使用STDIN的命令,shell输出开始无法正常工作。例如,光标移动了。

This is the case with this kind of commands using directly the STDIN cat | echo hello or tr | ls

我检查了它是否与未关闭的fd不相关...我在dup2时立即关闭了管道的写端。我在子进程中关闭了管道的读取端,而在管道的写入端处于关闭状态。

Besides, I don't understand the bash behavior of cat with the following command cat | echo. It gives back the prompt for one line and then stops, unlikely the cat command alone which continues and waits until it gets a stop signal.

如果有人有线索?