On Jan 16, 12:28 pm, Deanna Earley <
dee.ear...@icode.co.uk> wrote:
> On 10/01/2012 07:35, Andrew wrote:
>
> > I have written a windows service that launches other programs. I find
> > that certain programs I launch that I dont have the source for, do not
> > launch successfully unless I launch them via an intermediate batch
> > file. Does anyone have any ideas on whny this might be?
> How do they fail?
Err, yes, you're right, I should have given more detail. The process
creation works, I get a pid back, but the process then exits
immediately. It is supposed to be a long-running process that writes
to its own logfile. The logfile does not get written so it is failing
VERY early on. With no logging it is very hard to see why.
> Is there an error from whatever "start process" function you're using or
> an exit code?
No. CreateProcess actually works. It is just that the process exits
right away before it has the chance to do any work at all.
> What does process monitor show?
The process is too short-lived to reveal anything.
> Are all the paths set correctly?
Yes. This can be proved by making it launch a DOS batch file that just
has the set command to dump all environment variables, including PATH.
I managed to make my launching program work. I use Poco, the portable
multi-platform C++ foundation class library. It has a class, Process,
for launching processes. On Windoze this calls CreateProcess. I
changed the code so that it sets inheritHandles to FALSE and the
options flags to CREATE_NO_WINDOW. This makes it work. This also
demonstrates that the environment is correct, that the right
environment variables are there, that it can load all the DLLs etc.
However, I am not sure this hack is right for Poco, since Poco offers
I/O redirection in its launch method. I have a feeling that
inheritHandles needs to be TRUE for that to work. I need to find out
more about what happens with I/O when a launched process does not
inherit the handles. Suppose it writes to std::cout. Where does the
output go?
>
> --
> Deanna Earley (
dee.ear...@icode.co.uk)
> i-Catcher Development Teamhttp://
www.icode.co.uk/icatcher/
>
> iCode Systems
>
> (Replies direct to my email address will be ignored.
> Please reply to the group.)
Many thanks for your reply, I really appreciate it :-)