-
Notifications
You must be signed in to change notification settings - Fork 124
Description
Describe the bug
The lsof +L1 command is a handy way to get a list of running binaries that have been replaced on disk during a system update and needs to be restarted. I used this on FreeBSD until a couple of years ago when the ZFS compatibility problems began. Since lsof now is working again with ZFS I was hoping that I could once again use this but it doesn't seem to work. I don't know if this is an lsof problem or FreeBSD problem so please bear with my while I show my test cases.
Expected behavior
TEST CASE 1 (WORKING) - Linux on ZFS
# uname -a
Linux 5.15.69-gentoo #2 SMP Sun Sep 25 19:50:38 CEST 2022 x86_64 Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz GenuineIntel GNU/Linux
# lsof -v
lsof version information:
revision: 4.96.3
lsof run before the upgrade. NLINK properly shows 1 on the running binary.
# lsof +L | grep -E 'COM|avahi' | grep -E 'COM|txt'
COMMAND PID TID TASKCMD USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME
avahi-dae 2702 avahi txt REG 0,23 147920 1 132060 /usr/sbin/avahi-daemon
lsof run after the upgrade. NLINK properly shows 0 on the running binary.
# lsof +L | grep -E 'COM|avahi' | grep -E 'COM|txt'
COMMAND PID TID TASKCMD USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME
avahi-dae 2702 avahi txt REG 0,23 147920 0 132060 /usr/sbin/avahi-daemon (deleted)
lsof +L1 properly lists the unlinked binary and even marks it as deleted.
# lsof +L1
avahi-dae 2702 avahi txt REG 0,23 147920 0 132060 /usr/sbin/avahi-daemon (deleted)
To Reproduce
TEST CASE 2 (NOT WORKING) - FreeBSD on UFS (I have tested this on ZFS also but the result is the same)
# uname -a
FreeBSD 13.1-RELEASE-p2 FreeBSD 13.1-RELEASE-p2 GENERIC amd64
# lsof -v
lsof version information:
revision: 4.96.4
lsof run before the upgrade. NLINK properly shows 1 on the running binary, same as on Linux.
# lsof +L | grep -E 'COM|dhcpd' | grep -E 'COM|txt'
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME
dhcpd 46398 dhcpd txt VREG 0,90 3092560 1 166884 /usr/local/sbin/dhcpd (/dev/ada0p2)
lsof run after the upgrade. NLINK now becomes blank instead of 0. Also the filename information is lost but that also happened back when this used to work.
# lsof +L | grep -E 'COM|dhcpd' | grep -E 'COM|txt'
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME
dhcpd 46398 dhcpd txt VREG 0,90 3092560 166884 / (/dev/ada0p2)
lsof +L1 produces no output.
# lsof +L1
An additional observation: On FreeBSD NLINK goes blank as soon as the Ports build process starts, not when the binary is replaced on disk which I would've expect. This is the reason why I'm unsure whether this is an lsof problem or a FreeBSD problem. If I instead use the binary package to install the upgrade, the process is so fast I can't monitor when NLINK turns blank but it still turns blank and the end result is the same.
I have tested multiple packages and they all display the same behaviour.
I have tested both UFS and ZFS on FreeBSD and it makes no difference.
Environment (please complete the following information):
Information included in the test cases above.