A question related to pipe# Programming - 葵花宝典
s*g
1 楼
i have two programs, P1 print one line of data to stdout every 1 sec.
P2 read in data from stdin and do some processing, now I am using pipe
as follows in linux:
P1 | P2
what happens is that P2 is not getting data from the pipe every sec, it
seems
that it wait for the pipe to be filled full by P1, and read a lot of lines
out.
My question is: why the pipe performs like this way? wouldn't P2 should
read one line as soon as it sees a '\n'?
P2 read in data from stdin and do some processing, now I am using pipe
as follows in linux:
P1 | P2
what happens is that P2 is not getting data from the pipe every sec, it
seems
that it wait for the pipe to be filled full by P1, and read a lot of lines
out.
My question is: why the pipe performs like this way? wouldn't P2 should
read one line as soon as it sees a '\n'?