pipe

Simulate the Linux command tee in C

淺唱寂寞╮ 提交于 2020-11-29 10:11:09
问题 I have to do the simulation of the command tee in C for Linux. How does tee work internally? It looks like a T-shaped pipe, so should I use a pipe? Is there a special kind of pipe? 回答1: tee takes stdin and copies the data stream to stdout as well as a file given as an option, it can be used in many very different situations. An implementation in C is quite simple, just make a program that copies all data from stdin to stdout, but also use the same output statements for stdout on a file that