Re: child process in windows services
From: John Phillips (jjphillipsREMOVE_at_REMOVEhotmail.com)
Date: 03/16/04
- Next message: tico: "window scripting"
- Previous message: Gavin Stark: "Multiprocessor TimerQueueTimer precision question"
- In reply to: Anonuser: "Re: child process in windows services"
- Next in thread: Anonuser: "Re: child process in windows services"
- Reply: Anonuser: "Re: child process in windows services"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 16 Mar 2004 09:06:18 -0500
Is A.exe a service by any chance? If not, just how will it report its
status back to the SCM? Or do you mean that the application is designed to
report its status to its parent or to whomever is interested in A's status?
If A is a service, then the answer is simple: either make your service
dependant on A (so that A will start before your service and if it fails,
then your service will stop), or start A from your service using
StartService(). If you start a service via StartService(), then yes, the
newly started service will post its status to the SCM correctly. It's not
really a matter of who starts the service (your service vs. SCM vs. anybody
else), but if your service application -=behaves=- correctly, by calling the
requisite service registration function on startup, passing a handler
function. Also, the service must be registered via the appropriate registry
entries; statii reporting to the SCM for unregistered services will fall on
deaf ears.
What to do to monitor A from B? Well, that depends on what you want to do.
If A is a service, then you can periodically check its status with
QueryServiceStatus(). Otherwise, you can use one of the WaitForxxxObjects()
functions to wait on A's process handle - when A terminates, the handle
becomes signalled, and WaitFor...() will succeed.
-- John Phillips MVP - Windows SDK "Anonuser" <mycorolla02@yahoo.com> wrote in message news:32946381.0403151929.52fa2f97@posting.google.com... > Hi John, > Thanks for the reply. Here is a more detailed description. > > I have a service which launches process A.exe. A.exe is a third party > process to which I dont have access. I want to create a wrapper around > A or an intermediate process called B.exe. > > Not my service launches process B.exe which internally sets some > environment variables and does a create process to launch A.exe. > > A.exe was initially built to report status back to the Service > control manager. > I have two choices. > So from B.exe if I make a call to SErvice_Main (or equivalent) for > A.exe then A.exe will think that is started by a service and then > report status like STARTED, PENDING. Will these reach the Service > Control Manager since A.exe is the child of process it(SCM) launched. > > OR > > if i directly do a createprocess in B.exe (to create A.exe) to launch > it as an application. What all do I need to do in B.exe to correctly > monitor A's status? > > What will happen if B fails but A is still hanging? What status will > be reported back to SCM(Service control manager)? > > Thanks > > > > "John Phillips" <jjphillipsREMOVE@REMOVEhotmail.com> wrote in message news:<#xQ8cdpCEHA.3344@tk2msftngp13.phx.gbl>... > > Please see inline... > > > > > > -- > > John Phillips > > MVP - Windows SDK > > > > > > "Anonuser" <mycorolla02@yahoo.com> wrote in message > > news:32946381.0403131419.7c20251d@posting.google.com... > > > I have a service which calls into an exec by the name A.exe. Can I > > > > I don't know what you mean by "calls into an exec". Do you mean "launches a > > process"? > > > > > > > write a wrapper around A.exe called B.exe which basically does some > > > custom settings( settng Env variables) and then call A.exe. So A.exe > > > > Certainly. The environment settings of the parent are passed to the child > > process when calling CreateProcess() and passing NULL for the lpEnvironment > > parameter. > > > > > > > is the child of B.exe. Would service update messages sent by A.exe be > > > passed to the Service control manager. What all functions do I need to > > > > I'm still foggy about which of these things are services (B I assume is > > not). But assuming A is launched by a service, then the answer is no. > > SetServiceStatus() requires a handle to the service which is sending its > > status, and I'm pretty sure that these handles can't be duplicated with > > DuplicateHandle(). One way you might accomplish this is for A to send > > messages to the service (via some IPC method such as COM, Window Messages, > > Pipes, etc., etc., etc.), and the service would call SetServiceStatus() > > based on the content of the message. > > > > > > > write in the code for B.exe. > > > > You haven't mentioned what B is supposed to do, so this isn't really a valid > > question. > > > > > > > > When A.exe dies will the service control manager report the service as > > > stopped? > > > > No, unless the service tells the SCM that it is stopped. When A dies, it > > can instruct the service to stop, via some IPC mechanism (see above). > > > > > > > Would I have to monitor A.exe's state in B? I cannot put these custom > > > settings into A.exe. > > > > Really can't say, seeing as how you're a little short on details. > > > > > > > Thanks
- Next message: tico: "window scripting"
- Previous message: Gavin Stark: "Multiprocessor TimerQueueTimer precision question"
- In reply to: Anonuser: "Re: child process in windows services"
- Next in thread: Anonuser: "Re: child process in windows services"
- Reply: Anonuser: "Re: child process in windows services"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|