I use nodejs to captured its child process\'s stdout data, but always captured the former part of child process\'s stdout data. When I add fllush(stdout),It wor
By default, stdout in general is buffered until a newline is written. However, if stdout is not a tty (which is the case here with child_process.spawn()), all output is buffered, regardless of newlines.
If you don't want to use fflush() manually, you can disable stdout buffering entirely by doing setbuf(stdout, NULL); once at the beginning of your C program.