I have a C program that is compiled within Visual Studio. The C program contains a parent process and a child process that do some tasks of its own. In the program there are also some fprintf that prints out debug statements to stderr. Here is the problem, when I put fprintf to the program, the program would crash. But when the fprintf statement is commented out, the program executes successfully. I tried to replace fprintf with printf, the
program also executes without any problem. I then tried to open a file and makes fprintf output to that file, and no problem. I suspect that there is something wrong with stderr, either not open, or just simply not available?
I know stderr is available on Win32 API, so I even wrote a simple program (without CreateProcess) that has fprintf to stderr, and the program executes without any problem.
Could stderr not available to child process? Has anyone had seen this problem earlier?
If this helps,
I've tried to execute "ferror(stderr);" and the return code is 32.