dhclient pid file is not getting deleted when process dies
I am observing that dhclient does not delete the pid file created by it when process exits.
Is this the expected behavior? Should dhclient itself should have removed the pid file, or is the user expected to manually remove the pid file? Are there any documented guidelines on this?
# cat /var/run/myclient.pid
cat: /var/run/myclient.pid: No such file or directory
# dhclient -d -v eth2 -1 -pf /var/run/myclient.pid
Internet Systems Consortium DHCP Client 4.4.3-P1
Copyright 2004-2022 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/eth2/20:78:52:ff:5f:2e
Sending on LPF/eth2/20:78:52:ff:5f:2e
Sending on Socket/fallback
DHCPDISCOVER on eth2 to 255.255.255.255 port 67 interval 3 (xid=0x49fb9b59)
DHCPDISCOVER on eth2 to 255.255.255.255 port 67 interval 3 (xid=0x49fb9b59)
DHCPDISCOVER on eth2 to 255.255.255.255 port 67 interval 5 (xid=0x49fb9b59)
DHCPDISCOVER on eth2 to 255.255.255.255 port 67 interval 10 (xid=0x49fb9b59)
DHCPDISCOVER on eth2 to 255.255.255.255 port 67 interval 17 (xid=0x49fb9b59)
DHCPDISCOVER on eth2 to 255.255.255.255 port 67 interval 9 (xid=0x49fb9b59)
DHCPDISCOVER on eth2 to 255.255.255.255 port 67 interval 14 (xid=0x49fb9b59)
No DHCPOFFERS received.
Unable to obtain a lease on first try. Exiting.
# cat /var/run/myclient.pid
406186
#
If I understood the behavior correctly, on startup dhclient will check whether the pid mentioned in pid file is alive. If pid is alive,it exits with error dhclient(<pid>) is already running - exiting.
.
What if the pids in Linux are recycled and reused for a different process?
i.e if 406186
in above example is later assigned to another process that stays alive, next invocation of dhclient will fail.
Another possibility is that if the path in which pid file is stored in persistent over system reboot, there is a high chance that 406186
gets assigned to another process that stays alive and invocation of dhclient will fail after system reset.
System details:
# dhclient --version
isc-dhclient-4.4.3-P1
OS: Linux