What gives?
Brian
> I am trying to use popen within a service
> but it always fails.
Let me consult my crystal ball. Hmmm ... <intense concentration> ...
<deep frown> ... nope. Sorry, but "it always fails" is not enough info
for my crystal ball to work on.
Cheers,
Felix.
--
If you post a reply, kindly refrain from emailing it, too.
Do you know if I am write about stderr and stdout for services?
Brian
> Do you know if I am write about stderr and stdout for services?
It depends on whether you have a console or not. The easiest way to
circumvent that is to handle your pipes yourself:
Use CreatePipe() to create two pipes (better, three -- one for
stderr). Let's call them In, Out, Err, as seen from the program you
will start.
For each pipe you will get two handles, as in In_read and In_write.
Use DuplicateHandle() to make the following handles inheritable:
In_read --> In_read_inh
Out_write --> Out_write_inh
Err_write --> Err_write_inh
Close the non-inheritable copies (Inh_read, Out_write, Err_write).
Now, plug the inheritable handles into the STARTUPINFO structure and
set STARTF_USESTDHANDLES in its dwFlags member. Call CreateProcess().
Right afterwards, close the inheritable handles In_read_inh,
Out_write_inh, Err_write_inh.
You are left with three pipe handles, In_write (to write something to
the child's stdin), Out_read, and Err_read.
Do your thing and close the handles.