If I call CloseHandle on a mutex before a thread has finished with the mutex, and hence, hasn't yet called ReleaseMutex, what is the expected behaviour?
CloseHandle()
immediately destroys the handle that is passed to it. ReleaseMutex()
will then fail with an ERROR_INVALID_HANDLE
error code if called with the closed mutex handle.
If the mutex is named, there is a single reference-counted kernel object backing the mutex, but CreateMutex()
and OpenMutex()
return unique HANDLE
values that have to be closed individually. If multiple handles to the same named mutex are created/opened, calling CloseHandle()
on one handle does not effect the other handles to the same mutex.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With