summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qlockfile_win.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-09-29 09:59:18 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-11-14 15:54:56 +0000
commit772863355a0cf57a49e93608790dfd17c8fd82da (patch)
tree5bece011b9465288e23c941563a3c887c5536c98 /src/corelib/io/qlockfile_win.cpp
parent68cad0ef99b071cf03b8477d828f732485fca16b (diff)
QLockFile/Unix: save the boot and machine IDs in the lock file too
This allows us to make sure that the PID we read is from the same boot as we are right now running. The collision could happen on embedded systems where the boot sequence is fixed, so all the same processes would have the exact same PIDs after reboot as they did before. [ChangeLog][QtCore][QLockFile] QLockFile can now properly conclude that a lock file from a previous boot of the same device is stale and can be removed. This is implemented only for Linux and Apple operating systems. Task-number: QTBUG-63425 Change-Id: I0b48fc8e90304e0dacc3fffd14e8e3a197211788 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/corelib/io/qlockfile_win.cpp')
-rw-r--r--src/corelib/io/qlockfile_win.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp
index de64ec0432..6b8028460c 100644
--- a/src/corelib/io/qlockfile_win.cpp
+++ b/src/corelib/io/qlockfile_win.cpp
@@ -68,7 +68,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
#ifndef Q_OS_WINRT
SECURITY_ATTRIBUTES securityAtts = { sizeof(SECURITY_ATTRIBUTES), NULL, FALSE };
HANDLE fh = CreateFile((const wchar_t*)fileEntry.nativeFilePath().utf16(),
- GENERIC_WRITE,
+ GENERIC_READ | GENERIC_WRITE,
dwShareMode,
&securityAtts,
CREATE_NEW, // error if already exists
@@ -76,7 +76,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
NULL);
#else // !Q_OS_WINRT
HANDLE fh = CreateFile2((const wchar_t*)fileEntry.nativeFilePath().utf16(),
- GENERIC_WRITE,
+ GENERIC_READ | GENERIC_WRITE,
dwShareMode,
CREATE_NEW, // error if already exists
NULL);