diff options
author | Juha Riihimäki <juha.riihimaki@nokia.com> | 2009-12-03 15:56:03 +0200 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2009-12-18 23:23:56 +0100 |
commit | 099fe236d5e37e8477d17fae09f398bb49eebc13 (patch) | |
tree | 687d79961d8f49d98b642bf3b4b86dbfdb5f1e17 /osdep.c | |
parent | 1e8b27ca853d26e8854dc1a3e7ce88605e1673b9 (diff) | |
download | qemu-099fe236d5e37e8477d17fae09f398bb49eebc13.tar.gz qemu-099fe236d5e37e8477d17fae09f398bb49eebc13.tar.bz2 qemu-099fe236d5e37e8477d17fae09f398bb49eebc13.zip |
fix pidfile option to work in WIN32
Explicit read/write locking pidfile under WIN32 is bit extreme
nobody get the chance to read the pidfile. Convert to a write-only lock.
Also, creating pidfile was disabled along with daemonize under
WIN32. Enable it, but do not enable daemon support which doesn't
exist under WIN32 atm.
From: Juha Riihimäki <juha.riihimaki@nokia.com>
Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'osdep.c')
-rw-r--r-- | osdep.c | 13 |
1 files changed, 2 insertions, 11 deletions
@@ -133,25 +133,16 @@ int qemu_create_pidfile(const char *filename) return -1; #else HANDLE file; - DWORD flags; OVERLAPPED overlap; BOOL ret; + memset(&overlap, 0, sizeof(overlap)); - /* Open for writing with no sharing. */ - file = CreateFile(filename, GENERIC_WRITE, 0, NULL, + file = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (file == INVALID_HANDLE_VALUE) return -1; - flags = LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY; - overlap.hEvent = 0; - /* Lock 1 byte. */ - ret = LockFileEx(file, flags, 0, 0, 1, &overlap); - if (ret == 0) - return -1; - - /* Write PID to file. */ len = snprintf(buffer, sizeof(buffer), "%ld\n", (long)getpid()); ret = WriteFileEx(file, (LPCVOID)buffer, (DWORD)len, &overlap, NULL); |