Running Processes from a Service
Posted on 1999-07-29
I'm trying to write a service in Win NT that acts as a auto-starter which starts other processes. I will start the process by calling CreateProcess() in ServiceMain(), which works fine.
But it's not so good when the created process crashes. There seems to be no console associated with the created process (it's a console app.) and it sort of lingers as a runaway process, taking up memory space. I can't kill it, even with the task manager, and the only way I can remove it is to restart.
I've written my service such that it will restart the process if it comes down for any reason, but this 'lingering process' problem would not allow me to do that. My process therefore fails and would not recover automatically.
Making the process crash-proof is the ultimate solution of course (let's just say I'm in the midst of sorting THAT out), but I'm more interested right now in the mechanics of creating processes inside services, because I need to behaviour of these processes to be at least manageable.
PS: I'm apologise for offering a bit low on points - it's all I have at the moment!!