Re: Win32 TerminateProcess problem

Emil Dotchevski <[email protected]>
Newsgroups gmane.games.devel.sweng
Message-ID <[email protected]>
On Wed, Feb 3, 2010 at 10:47 PM, Jim Tilander <[email protected]> wrote:
>
> TerminateProcess does leak resources, on all NT kernels. Yes, that includes
> whatever you run. I'm not even including Win98 or lesser, they are not even
> production "OS"s anyways. For anyone curious, you should first read the man
> page on TerminateProcess
> (http://msdn.microsoft.com/en-us/library/ms686714(VS.85).aspx ... yes RTFM).
> This is not a "theoretical" case, if you have any DLLs attached (and you
> most probably will for any but the most trivial of applications) you *will*
> leak resources. We had this in our pipeline and it took blood sweat and
> tears to track this one down (happend during distribution of our "simple"
> tools, and it leaked every time things timed out. Over the course of
> hundreds of thousands of these builds machines on the network quickly
> experience slowdowns and "random" crashes).

Oh dear.

Well, I was referring to this post, which indicates that ExitProcess
should not be called at random because it can lead to serious
problems; and injecting a thread that calls it strikes me as rather
random:

http://blogs.msdn.com/oldnewthing/archive/2007/05/03/2383346.aspx

Then there is this correction, which says that on Vista and on, if you
call ExitProcess and then hit a synchronization primitive, it'll call
TerminateProcess on you:

http://blogs.msdn.com/oldnewthing/archive/2010/01/22/9951750.aspx

It seems like the only way to quit safely is to first exit all your
threads cleanly and then exit the process.

In my particular use case however, I'm calling TerminateProcess on
another process before any of its DLLs have a chance to load. So I
still need a way to get the exit code I pass to TerminateProcess
propagate correctly...

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode
_______________________________________________
Sweng-Gamedev mailing list
[email protected]
http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.