sp0987 0 Posted yesterday at 01:10 PM Hi, We have a windows service sample application developed using D11. Observed that even after the service destroyed, the executable still showing in the background for 20sec's. When looked for help i found this "When a Windows service is destroyed , the service itself is removed from the running processes, but the executable file (.exe) might still appear in the process list because the underlying process hosting the service (often "svchost.exe") remains running, even if it no longer actively manages the service you deleted; essentially, the executable is still in memory but is not actively performing any service-related functions". Though it's a zombie exe, but still when we run the same exe multiple times , we could able to see the more than one zombie exe's in the process tab in task manager. Share this post Link to post
David Heffernan 2379 Posted yesterday at 01:39 PM Do you have a question? Share this post Link to post
DelphiUdIT 209 Posted yesterday at 01:43 PM @sp0987 And, what are your needs ? If the service maintain the zombies for some seconds ... it is so, but really I never see this. When I stop a service the EXE disappear from task manager (of course, if the application has no pending things like threads waiting). If you want that the same exe doesn't run more then one time, use a mutex at the start of the application: var hMutex: THandle; // Creates a unique synchronized object in the operating system hMutex:=CreateMutex(Nil,False,'Global\MyApplication'); // Checks that the object is not already 'owned' by some other process (program instance), // in which case exits the program if (WaitForSingleObject(hMutex,0) = wait_TimeOut) then exitprocess(255); Share this post Link to post
sp0987 0 Posted yesterday at 02:43 PM Am sorry... 1 hour ago, sp0987 said: "When a Windows service is destroyed , the service itself is removed from the running processes, but the executable file (.exe) might still appear in the process list because the underlying process hosting the service (often "svchost.exe") remains running, even if it no longer actively manages the service you deleted; essentially, the executable is still in memory but is not actively performing any service-related functions". As per this was it ok for the exe to stay in the background for a period of time? Share this post Link to post
DelphiUdIT 209 Posted yesterday at 05:58 PM I don't know where you catch those info. Like I told, my experience, I nevere see an executable (service or not service) stay live after "termination". In my developer machine runs only basic services, and i start and stop programmatically the services that I need project based (normally 4/5 services for 4 times per days). May be is a "design basis" by Windows for some kinds of executables or (more likely) some thread or method of the executable is "hanging". 20 seconds is historically the standard timeout within which a closing service is killed by the system, if it does not terminate itself (I remember a value like "KillServiceTimeout" in the registry that keeps the default time, but it could be called something different). Share this post Link to post