Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
run qsd with pidfile and daemonize options. the pid file still exist after qsd process be killed.
Version-Release number of selected component (if applicable):
Red Hat Enterprise Linux release 9.1 Beta (Plow)
5.14.0-101.el9.x86_64
qemu-kvm-7.0.0-4.el9.x86_64
seabios-bin-1.16.0-3.el9.noarch
edk2-ovmf-20220221gitb24306f15d-2.el9.noarch
virtio-win-prewhql-0.1-221.iso
How reproducible:
100
Steps to Reproduce:
1.boot qsd with pidfile and daemonize options
qemu-storage-daemon \
--chardev socket,path=qmp.sock,server=on,wait=off,id=char1 \
--monitor chardev=char1 \
--pidfile qsd.pid \
--daemonize \
2.check the process
pgrep -l -x -F qsd.pid|grep qemu-storage-da
3.kill process
kill -SIGTERM $(<qsd.pid)
4.check the process
pgrep -l -x qemu-storage-da
5.check the pid file
Actual results:
pif file qsd.pid still exist on disk
Expected results:
This file should be deleted after qsd process quit.
Additional info:
It meet expected result if run without daemonize
The problem is that daemonizing changes the current working directory to /, so the PID file cannot be removed if it was specified by relative path. This is also true for qemu itself:
$ pwd
/tmp
$ qemu-system-x86_64 --daemonize --pidfile qemu.pid
$ kill $(cat qemu.pid)
$ ls -l qemu.pid
-rw------- 1 hreitz users 6 9. Jun 09:38 qemu.pid
We should probably always expand the PID file path to absolute paths internally.
(In reply to qing.wang from comment #3)
> root@dell-per6515-03 /home $ qemu-storage-daemon --daemonize --pidfile
> /tmp/qemu.pid
> root@dell-per6515-03 /home $ ps -e ww|grep qemu-storage-daemon|grep -v grep
> 208762 ? Sl 0:00 qemu-storage-daemon --daemonize --pidfile
> /tmp/qemu.pid
> root@dell-per6515-03 /home $ kill -9 208762
If you kill the process via SIGKILL, it has no chance to delete the PID file. This should be the case with or without --daemonize.
The PID file can only be deleted if the process is terminated such that atexit() handlers run, e.g. via SIGTERM (as done in comment 0) or SIGINT.
Hanna
verify on qemu-kvm-7.0.0-8.el9.x86_64:
1.qemu-storage-daemon --daemonize --pidfile /tmp/qemu.pid
2.kill -SIGTERM $(cat /tmp/qemu.pid)
3. ps -e ww|grep qemu-storage-daemon|grep -v grep
4. ls /tmp/qemu.pid
ls: cannot access '/tmp/qemu.pid': No such file or director
It get expected result.
I suggest adding this to document or help message.