[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] bug writing pidfile under unix (and fix)

From: Jim Bailey
Subject: Re: [Qemu-devel] bug writing pidfile under unix (and fix)
Date: Fri, 7 Nov 2008 18:08:42 +0000

Hi Paul,

Opening with O_TRUNC causes a problem. If you try and start qemu again
(by accident presumably) it opens the pidfile and then fails to acquire
a lock on it. It then exits with a useful message "Could not acquire
pidfile" and you know that is has just saved you from trashing your

If we open the file with O_TRUNC the contents get discarded before the
lock is checked, so although a second instance wouldn't run, it would
still leave you with an empty pidfile for your still-running first

I hope that makes sense.

Removing the file on exit would also be a great feature.


On Fri, 7 Nov 2008 18:56:11 +0100
Paul Brook <address@hidden> wrote:

> On Friday 07 November 2008, Jim Bailey wrote:
> > Hello,
> >
> > In qemu_create_pidfile (osdep.c:229) the current pid and a newline is
> > written to the pidfile. However, the pidfile isn't truncated, so if it
> > is longer than the length of the pid and the newline character you get
> > trailing junk that can really mess up scripts.
> Shouldn't we just open with O_TRUNC ?
> I also notice that we're not removing the file when we exit.
> Paul

reply via email to

[Prev in Thread] Current Thread [Next in Thread]