I notice that Process::launch delegates to a an impl method that always supplies inheritHandles as TRUE to CreateProcess (this is for the windoze implementation). It creates pipes when null pipe pointers are supplied. This happens when launch is called with no pipe parameters. I think this causes a problem when the program doing the launching is a windoze service. The program launches (i.e. a process handle is returned) but the program exits with an error status as soon as it writes to std::cout.
I hope someone can explain why the impl launch method does some I/O redirection even when null pipe pointers are supplied. Using redirection does explain why inheritHandles is set to TRUE but why do the redirection if the caller is not supplying pipes?
I hacked my Poco environment, setting inheritHandles to FALSE and creationFlags to CREATE_NO_WINDOW. This fixed my program. It can now launch processes ok when my process is running as a windoze service. But what is going on here? I can't submit this change as a patch because I don't know enough about what it going on when the pipe pointers are supplied as null.
I have a horrible feeling that one cannot capture the output of a program that is launched from a program that runs as a service. I hope I'm wrong but that's how it feels to me. If this turns out to be correct then I think it would be good if the impl launch could somehow figure out if it is running as a service. If so then it can pass inheritHandles and creationFlags as I do. I don't know how it might make this determination. It might not be possible, in which case it might need an additional parameter to the Process::launch method. That would be horrible but, hey, it's windoze!