mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
Separate qemu_pidfile() into OS specific versions
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
ff753bb9a6
commit
bc4a957c46
3 changed files with 45 additions and 38 deletions
24
os-win32.c
24
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue