I need to create a new process with redirected standard error stream to some file. The code from which child process is being created has no console available, so there are cases when GetStdHandle(any) will return 0. Child process will try to duplicate all of its standard IO handles for some reason (source code for child process is unavailable) so all of it's handles should be valid.
So I need to run that process in the same manner as it's can be ran from the console with: someproc nul 2>err
I see some ways for this: 1. Create two pair of pipes. This is possibly good solution, but it will be too complex for me. 2. Open "nul" file with CreateFile("nul", ...) function call. No file is being created by this call, but this looks weird too me. 3. Use INVALID_HANDLE_VALUE. This works too, but I think there can be different problems with another child processes.
I believe there are better ways.