]> git.proxmox.com Git - mirror_qemu.git/commit
qsd: Unlink absolute PID file path
authorHanna Reitz <hreitz@redhat.com>
Thu, 9 Jun 2022 12:26:59 +0000 (14:26 +0200)
committerHanna Reitz <hreitz@redhat.com>
Tue, 12 Jul 2022 12:30:38 +0000 (14:30 +0200)
commit9d8f8233b9fa525a7e37350fbc18877051128c5d
treee5dfd444d9e1009373e638bea4fee9f20c9a9c31
parent9907dba91dbcde20a8f966c8f22ae1635c5f7e78
qsd: Unlink absolute PID file path

After writing the PID file, we register an atexit() handler 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 atexit() handler.

(realpath() needs a path pointing to an existing file, so we cannot use
it before qemu_write_pidfile().)

Reproducer:
$ cd /tmp
$ qemu-storage-daemon --daemonize --pidfile qsd.pid
$ file qsd.pid
qsd.pid: ASCII text
$ kill $(cat qsd.pid)
$ file qsd.pid
qsd.pid: ASCII text

(qsd.pid should be gone after the process has terminated.)

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2092322
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220609122701.17172-2-hreitz@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
storage-daemon/qemu-storage-daemon.c