When a process that locked a lockfile crashes on Windows, sometimes
a new instance of the process fails to lock.
Unfortunately, I can't find a way to reproduce the problem consistently,
but it happens from time to time with Qt Creator and Qbs.
There are several ways to detect a dead process on Windows. Some of
them can be found in stackoverflow[1].
The current implementation of stale lock detection is based on the
second answer (using WaitForSingleObject), but apparently it doesn't
work in 100% of the cases.
The most voted answer[2] (using GetProcessExitCode) proves to work also
on this case.
[1] http://stackoverflow.com/q/1591342/764870
[2] http://stackoverflow.com/a/1591379/764870
Task-number: QTBUG-53392
Change-Id: Ied7bf00985d0f12e833b887a0143f7bdeee3e772
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>