From 93dd748b789202af4f5be75412c58ee1ed481b29 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Fri, 27 Jan 2012 14:34:05 +0100 Subject: keep the PID file locked for the lifetime of the process The lockf() call in qemu_create_pidfile() aims at ensuring mutual exclusion. We shouldn't close the pidfile on success (as introduced by commit 1bbd1592), because that drops the lock as well [1]: "File locks shall be released on first close by the locking process of any file descriptor for the file." Coverity may complain again about the leaked file descriptor; let's worry about that later. v1->v2: - add reference to 1bbd1592 - explain the intentional fd leak in the source [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/lockf.html Signed-off-by: Laszlo Ersek Signed-off-by: Anthony Liguori --- os-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os-posix.c') diff --git a/os-posix.c b/os-posix.c index 5c437ca12c..e3ed497224 100644 --- a/os-posix.c +++ b/os-posix.c @@ -348,6 +348,6 @@ int qemu_create_pidfile(const char *filename) return -1; } - close(fd); + /* keep pidfile open & locked forever */ return 0; } -- cgit v1.2.3