ExitProcess is for ending the process itself (much like ExitThread ends a thread). This is used to end a process (program or DLL), though Microsoft doesn't recommend it for ending a DLL.
If you are trying to stop yourself (you are the process), you can use ExisProcess, though I would recommend a cleaner shutdown, to make sure everything is cleanly stopped. ExitProcess, like ExitThread, stops without unwinding the stack, so no destructors are called.
From within a service, you stop based on an external signal. You could respond to that by calling ExitProcess, but it would probably be better to have some form of the shutdown that closes anything necessary and logs this.
Lua has os.exit(), but this use to the end of the process itself. Similar to closeCE().
Test:
Code:
function onExitProcess()
local id = getOpenedProcessID()
local name = getProcessNameFromID(id)
if tostring(name) == "" then
showMessage("Process not found...")
return
end
os.execute("taskkill -im "..id)
--- do something on exit process here
end
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Joined: 25 Jan 2006 Posts: 8585 Location: 127.0.0.1
Posted: Tue Mar 31, 2020 11:36 pm Post subject:
If you are referring to an event fired for when the process closes that CE attached to, you can do something like this:
- Add a 'onOpenProcess' event handler in your Lua code.
- Store the process id it passes as its argument.
- Create a timer that loops the process list of the system and checks for the process id you stored to ensure it still exists.
- If the process id is missing, kill the timer and call your own onExitProcess function. _________________
atom0s, how if CE has open as multi-instances with the same process attached. It is possible to use the method as multithreading especially in CE Lua?. _________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum