Re: [dhcpcd] writing to resolv.conf seems to be delayed
Roy Marples
Tue Jan 09 10:34:29 2018
Hi
On 09/01/2018 00:33, Barry Kauler wrote:
Hi,
Have just joined the list.
I have used dhcpcd for years, for Puppy Linux, however, fairly
recently something odd happened.
DHCPCDFIX="-I ''"
MODTIME1="`stat --format=%Y /etc/resolv.conf`"
dhcpcd $DHCPCDFIX $INTERFACE
sleep 0.1
MODTIME2="`stat --format=%Y /etc/resolv.conf`"
[ "`grep -v '^#' /etc/resolv.conf`" == "" ] && MODTIME2="$MODTIME1" #fail.
if [ "$MODTIME2" != "$MODTIME1" ];then
In the above code, I had to introduce that "sleep 0.1". Without it, I
was sometimes getting MODETIME2 the same as MODTIME1, even though
dhcpcd had succeeded.
How could this problem even be possible? Unless /etc/resolv.conf is
written-to asynchronously or as a separate process, and dhcpcd exits
before the write happens?
Or, does bash start executing the next line before dhcpcd completes?
No, bash does not start executing the nest line.
dhcpcd will hand off writing resolv.conf to a separate process as
documented in dhcpcd-run-hooks(8) and it's not async.
To see what dhcpcd is doing, add this to the top of /etc/dhcpcd.conf
debug
logfile /var/log/dhcpcd.log
Then redo your test.
You can examine /var/log/dhcpcd.log to see what dhcpcd did. It won't
document what each call out to dhcpcd-run-hooks does beyond the reason
but it might answer your query.
Roy
Archive administrator: postmaster@marples.name