pidfile is the same when running with -T
Pid file is the same regardless of interface name , when running with -T :
/run/.pid
Therefore it is impossible to run multiple instances of dhcpcd on different interfaces in test mode.
The bug doesn't exist in Ubuntu 22.04 ( dhcpcd 7.1.0) and appeared in Ubuntu 24.04 ( dhcpcd 10.0.6)
That's an odd one. Running separate instances of dhcpcd works fine if it's not in test mode. I wonder what test mode does differently to end up with the same PID file. That's clearly a mistake.
Why do you want to use test mode on many interfaces? Sounds like what you really want is the --noconfigure option?
Also, I can't replicate this at all. When running in test mode a pidfile is never created by dhcpcd.
Here is how to reproduce. Get a system with 2 network cards, echo them to the stdin of the script.
echo enp0s3 enp0s8 | xargs -n1| xargs -II -P10 -- bash -c 'bash -c "dhcpcd -4 -1 I -T | grep new_ip_ad" 2>&1 | sed "s@^@I==@" '|sort
Output :
enp0s3==DUID 00:01:00:01:2e:b6:24:a4:02:47:5b:32:b6:f2
enp0s3==dhcpcd exited
enp0s3==dhcpcd-10.0.6 starting
enp0s3==enp0s3: IAID 5b:32:b6:f2
enp0s3==enp0s3: leased 10.0.2.15 for 86400 seconds
enp0s3==enp0s3: rebinding lease of 10.0.2.15
enp0s3==new_ip_address='10.0.2.15'
enp0s8==dhcpcd exited
enp0s8==dhcpcd-10.0.6 starting
enp0s8==main: pidfile_lock 1076662: File exists
You see, they started to fight for the same pidfile. And its content is :
root@px24 [~] # cat /run/.pid
1076662
I need it to simply query DHCP server status on multiple interfaces without configuring them. Unfortunately --noconfigure doesn't output lots of useful info (full dump of the DHCP response).
So the solution would be to include interface name to the pidfile filename when running with -T.
fixed on my side with unshare -m bash -c "mount -t tmpfs -o size=10M tmpfs /run/; dhcpcd -1 $DEV -T"
--configure has all the information in the environment prefixed with _new. You could write an exit hook to dump this to a file as well if you wanted. I'm unsure how to replicate this though as in no instance does dhcpcd create a pidfile with -T for me.