diff options
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/WinLock.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Utility/WinLock.hs b/Utility/WinLock.hs index 369da6782..fc7c8a8a9 100644 --- a/Utility/WinLock.hs +++ b/Utility/WinLock.hs @@ -44,15 +44,20 @@ lockExclusive = openLock fILE_SHARE_NONE - Note that createFile busy-waits to try to avoid failing when some other - process briefly has a file open. But that would make checking locks - much more expensive, so is not done here. Thus, the use of c_CreateFile. + - + - Also, passing Nothing for SECURITY_ATTRIBUTES ensures that the lock file + - is not inheerited by any child process. -} openLock :: ShareMode -> LockFile -> IO (Maybe LockHandle) openLock sharemode f = do h <- withTString f $ \c_f -> - c_CreateFile c_f gENERIC_READ sharemode (maybePtr Nothing) + c_CreateFile c_f gENERIC_READ sharemode security_attributes oPEN_ALWAYS fILE_ATTRIBUTE_NORMAL (maybePtr Nothing) return $ if h == iNVALID_HANDLE_VALUE then Nothing else Just h + where + security_attributes = maybePtr Nothing dropLock :: LockHandle -> IO () dropLock = closeHandle |