|
-
February 4th, 2002, 11:23 AM
#1
Calling destructor with kill command
Hi everybody,
I have to work on a big application. This application consists in several processes.
The processes are launched with a batch file (START command).
When the administrator wants to stop the application, another batch file is launched. It contains KILL commands :
KILL process1
KILL process2
and so on.
It seems that the destructor of each application is not called.
Can someone confirm that last point ? If so, how can I do to detect the end of an application ?
Thanks.
-
February 4th, 2002, 01:31 PM
#2
Re: Calling destructor with kill command
A normal kill sends a message to the process - in Windows it is a WM_QUIT message, in console programming it is a signal SIGTERM.
Windows will normally handle the WM_QUIT message, but a SIGTERM has no standard handler and you have to write one.
Actually, I once implemented it by getting the SIGTERM to throw an exception! The main execution caught it because I did try..catch for this exception in main.
A hard kill (-9 in UNIX, or shutting down via Task Manager in NT when it is "not responding") will not send the application a message at all but will shut it down and no code, destructors or otherwise, will be called.
The best things come to those who rate
-
February 5th, 2002, 03:46 AM
#3
A question about memory leak
Thanks for your reply.
I have another question then. If the application allocates memory during execution, can I suppose that Windows will free automatically the objects allocated when the application will be killed ? If so, I don't have to worry about memory leak problems.
Thanks again.
-
February 5th, 2002, 06:59 AM
#4
Re: A question about memory leak
Heap memory is allocated by the heap manager, per-process. When your program shuts down, this memory will be freed automatically (on any operating system, as long as that operating system doesn't have bugs).
I don't know what happens about memory allocated with GlobAlloc (on Windows).
The best things come to those who rate
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|