On Thu, Jun 09, 2022 at 02:27:01PM +0200, Hanna Reitz wrote: > After writing the PID file, we register an exit notifier to unlink it > when the process terminates. However, if the process has changed its > working directory in the meantime (e.g. in os_setup_post() when > daemonizing), this will not work when the PID file path was relative. > Therefore, pass the absolute path (created with realpath()) to the > unlink() call in the exit notifier. > > (realpath() needs a path pointing to an existing file, so we cannot use > it before qemu_write_pidfile().) > > Reproducer: > $ cd /tmp > $ qemu-system-x86_64 --daemonize --pidfile qemu.pid > $ file qemu.pid > qemu.pid: ASCII text > $ kill $(cat qemu.pid) > $ file qemu.pid > qemu.pid: ASCII text > > (qemu.pid should be gone after the process has terminated.) > > Signed-off-by: Hanna Reitz <hre...@redhat.com> > --- > softmmu/vl.c | 30 ++++++++++++++++++++++++++---- > 1 file changed, 26 insertions(+), 4 deletions(-)
Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|