dhcpcd-discuss

[dhcpcd] writing to resolv.conf seems to be delayed

Barry Kauler

Tue Jan 09 00:33:33 2018

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?

Regards,
Barry

Follow-Ups:
Re: [dhcpcd] writing to resolv.conf seems to be delayedRoy Marples
Archive administrator: postmaster@marples.name