[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/7] fix pidfile option to work in WIN32
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PATCH 2/7] fix pidfile option to work in WIN32 |
Date: |
Thu, 3 Dec 2009 15:56:03 +0200 |
From: Juha Riihimäki <address@hidden>
Excplicit 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 <address@hidden>
Signed-off-by: Juha Riihimäki <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
osdep.c | 13 ++-----------
vl.c | 4 +++-
2 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/osdep.c b/osdep.c
index fd8bbd7..2ecffab 100644
--- a/osdep.c
+++ b/osdep.c
@@ -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);
diff --git a/vl.c b/vl.c
index 44763af..11f6ad0 100644
--- a/vl.c
+++ b/vl.c
@@ -5471,16 +5471,18 @@ int main(int argc, char **argv, char **envp)
signal(SIGTTOU, SIG_IGN);
signal(SIGTTIN, SIG_IGN);
}
+#endif
if (pid_file && qemu_create_pidfile(pid_file) != 0) {
+#ifndef _WIN32
if (daemonize) {
uint8_t status = 1;
write(fds[1], &status, 1);
} else
+#endif
fprintf(stderr, "Could not acquire pid file: %s\n",
strerror(errno));
exit(1);
}
-#endif
if (kvm_enabled()) {
int ret;
--
1.6.3.3
- [Qemu-devel] [PATCH 0/7] Misc fixes from maemo qemu, riku . voipio, 2009/12/03
- [Qemu-devel] [PATCH 3/7] fix networking on win32 host, riku . voipio, 2009/12/03
- [Qemu-devel] [PATCH 1/7] Fix win32 log file location, riku . voipio, 2009/12/03
- [Qemu-devel] [PATCH 4/7] Give a error when running out of iomem areas., riku . voipio, 2009/12/03
- [Qemu-devel] [PATCH 6/7] handle SD CMD5 without error messages, riku . voipio, 2009/12/03
- [Qemu-devel] [PATCH 7/7] usb-musb: convert fifo to 8bit and add more registers, riku . voipio, 2009/12/03
- [Qemu-devel] [PATCH 5/7] Make USB hid devices self-powered, riku . voipio, 2009/12/03
- [Qemu-devel] [PATCH 2/7] fix pidfile option to work in WIN32,
riku . voipio <=