diff options
-rw-r--r-- | os-posix.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/os-posix.c b/os-posix.c index dbf3b240f7..dc4a6bb3ff 100644 --- a/os-posix.c +++ b/os-posix.c @@ -372,13 +372,16 @@ int qemu_create_pidfile(const char *filename) return -1; } if (lockf(fd, F_TLOCK, 0) == -1) { + close(fd); return -1; } len = snprintf(buffer, sizeof(buffer), FMT_pid "\n", getpid()); if (write(fd, buffer, len) != len) { + close(fd); return -1; } + close(fd); return 0; } |