Hello
I want to redirect stdin/stdout/stderr of any console app to a pipe. the technique given in the relevant MSDN sample(http://msdn.microsoft.com/library/default.asp url=/library/en-us/dllproc/base/creating_a_child_process_with_redirected_input_and_output.asp) does not output to the pipe in case the child process uses printf() statements.. although if the child uses _write(), the output is redirected to the pipe correctly. I beleive this has something to do with the C-runtime printf function buffering data in i/o buffers before output. How does one redirect output in case the child process uses functions like printf
Please help.
John

redirecting stdin/stdout/stderr for windows console
DonHutson
jphamel
Is there a way to redirect the stdout of a child process to a socket in the parent process
i.e. the parent process creates a socket and then creates the child process so that its stdout is redirected to this socket
Thanks!!
Pierrelud
Marc
Nope. Never got around it. Though i believe there is a way to do it using the same technique as the Microsoft Telnet pgme.. apparently it creates a brand new console etc etc.
Sunny G.
If you happen to the write the child process yourself.. you might add fflush() after printf(). My problem is for child processes (or apps) which we havent written ourselves (cant change the code) and which use printf() statements.
str01014
fflush() is your best friend !!
Q190351
NOTE: Child processes that use such C run-time functions as printf() and fprintf() can behave poorly when redirected. The C run-time functions maintain separate IO buffers. When redirected, these buffers might not be flushed immediately after each IO call. As a result, the output to the redirection pipe of a printf() call or the input from a getch() call is not flushed immediately and delays, sometimes-infinite delays occur. This problem is avoided if the child process flushes the IO buffers after each call to a C run-time IO function. Only the child process can flush its C run-time IO buffers. A process can flush its C run-time IO buffers by calling the fflush() function.
rolfpf
John,
Did you ever find a solution I am having the same problem. It appears that when I redirect only the stdout stream from the child, this works, however when I redirect stdin also the output stream is only transmitted when I kill the child process.