Skip to content

Commit

Permalink
keep the PID file locked for the lifetime of the process
Browse files Browse the repository at this point in the history
The lockf() call in qemu_create_pidfile() aims at ensuring mutual
exclusion. We shouldn't close the pidfile on success (as introduced by
commit 1bbd159), 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 1bbd159
- explain the intentional fd leak in the source

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/lockf.html

Signed-off-by: Laszlo Ersek <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
  • Loading branch information
lersek authored and Anthony Liguori committed Feb 1, 2012
1 parent d34e8f6 commit 93dd748
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion os-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,6 @@ int qemu_create_pidfile(const char *filename)
return -1;
}

close(fd);
/* keep pidfile open & locked forever */
return 0;
}

0 comments on commit 93dd748

Please sign in to comment.