I have a self upgrade process implemented where my main application exe launches an updater exe passing a handle to itself on the command line. The application exe then calls ExitProcess to exit, and the updater calls WaitForSingleObject on the passed in handle to wait for the application exe to terminate.
The WaitForSingleObject does wait. Until the application calls ExitProcess the updater does stall.
However, sometimes, when the updater tries to overwrite the application dlls with the new versions I get a file-locked error which the current version of my updater treats as an unrecoverable error and terminates. It seems that including an arbitrary sleep(100) is sufficient to bypass this "issue" but I really hate code like that. really hate.
It seems very odd to me that the process handle can be signalled while the main application is still alive enough to have dll files locked.