diff options
author | Jes Sorensen <Jes.Sorensen@redhat.com> | 2010-10-26 10:39:25 +0200 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2010-10-30 08:02:39 +0000 |
commit | 081b9ee42e39a3b93ec574461502d8c2844977c2 (patch) | |
tree | e386df6724907c5e1b4bdf6535e4245c830086fe /os-win32.c | |
parent | db43cef7871652627d7b05a463454c5aa9ee5b62 (diff) | |
download | qemu-081b9ee42e39a3b93ec574461502d8c2844977c2.tar.gz qemu-081b9ee42e39a3b93ec574461502d8c2844977c2.tar.bz2 qemu-081b9ee42e39a3b93ec574461502d8c2844977c2.zip |
Separate qemu_pidfile() into OS specific versions
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'os-win32.c')
-rw-r--r-- | os-win32.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/os-win32.c b/os-win32.c index 3c6f50fa94..566d5e9853 100644 --- a/os-win32.c +++ b/os-win32.c @@ -240,3 +240,27 @@ void os_pidfile_error(void) { fprintf(stderr, "Could not acquire pid file: %s\n", strerror(errno)); } + +int qemu_create_pidfile(const char *filename) +{ + char buffer[128]; + int len; + HANDLE file; + OVERLAPPED overlap; + BOOL ret; + memset(&overlap, 0, sizeof(overlap)); + + file = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, + OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + + if (file == INVALID_HANDLE_VALUE) { + return -1; + } + len = snprintf(buffer, sizeof(buffer), "%ld\n", (long)getpid()); + ret = WriteFileEx(file, (LPCVOID)buffer, (DWORD)len, + &overlap, NULL); + if (ret == 0) { + return -1; + } + return 0; +} |