How to solve the problem of under Windows pipes blocked?
Time:09-22
The program is very simple: Program A: # include "stdio.h" Int main () { int index=0; int i=0; For (I=1; i <9988998; I++) { Printf (" Current Count is % d \ n ", index++);
Sleep (10 * 999); } }
Would be stuck through pipeline access to stdout, investigate its reason, is because Windows stdout is fully buffered output, output only buffer is full, but I want to achieve A line will output A line, under the command line can be so, but the pipe has been not achieve them, search on the Internet A lot of code, though, asynchronous access, but also must to output after buffer is full, the question now is I can't modify A program, the above is just A example, the actual function more complicated than it, but the principle is same, also can't change the Windows command line to line buffer, everybody has what good method?
CodePudding user response:
Output a newline character, or brush the fflush function force can?
CodePudding user response:
Using PeekNamedPipe data query the pipeline, have read, no, don't read, main is to prevent the ReadFile congestion,
CodePudding user response:
Should be able to realize, similar to the back door binding the CMD rebound, the console input and output are taken over,