Thankyou for your prompt reply. dhclient and the boot process do not work the way you are imagining in practice, and this does not break anything. The ifupdown process is usually backgrounded on the switch to runlevel 2 and it is only when this is not done that the problem occurs. Also the so called waiting done by dhclient is intended to provide a useful readout of the connection process when called manually. It is not intended to delay the boot process, and as it usually does NOT delay the boot process - because ifupdown has been automatically backgrounded - then it fails to wait as you suppose it is doing.
The actual cause of the bug is simply this: dhclient writes to stderr in runlevel S. In opening a connection to the console this causes the boot process to block until it finishes writing, because it is designed to deal with init scripts that finish promptly, not block for a minute. But it usually does not write until runlevel 2, when stdout has been redirected to /dev/null. This is the only reason dhclient does not ALWAYS cause a delay. The boot process is currently working in a flawed manner as it is relying on relative timing (which varies according to machine type and which software is installed) without my patch, and is basically an accident waiting to happen. If you really wanted to halt the boot process until an internet connection was established then you would need to be checking the output of netstat -nr or similar, calling dhclient without -nw just causes random delays and does not serve any useful purpose. Nor does it make any difference to the connection process whether dhclient is called with the -nw option as it will do exactly the same thing in making the connection, the only difference is that it does not give you constant updates on what it is doing via stderr. dhclient is a daemon - it is meant to be a daemon and run in the background. It just happens to have a neat user friendly function that you are inadvertently activating in the wrong situation. The init script should be starting dhclient as a daemon, not an interactive foreground process. It is a genuine mistake in ifupdown, which is often disguised by the boot process doing it's best to fix the resulting mess. If you want a simple fix then change the call to dhclient in inet.defn (up) to add the -nw option. The only reason I added the -d option was so users would get the nice output from dhclient when they call ifup manually. There is not much documentation that explains all this interaction, you need to look in the code to understand what I am explaining, and run some tests to see what actually happens, rather than only listening to what some old man page written before parallel boot systems were created tells you. That is not to say the documentation is wrong, rather incomplete in not listing the exceptions and oddities. Sorry you did not understand what I was trying to explain. If a real effort was made then I am sure Debian could have the main bugs fixed, but instead it always seems to be well lets rewrite everything, install this package or that package, rather than take the trouble to actually fix what is already there and then move forward from a solid base. Toodle pip. ________________________________ From: Debian Bug Tracking System <ow...@bugs.debian.org> To: Zebedee <electro1400cweld-sca...@yahoo.co.uk> Sent: Friday, 18 July 2014, 7:21 Subject: Bug#747048 closed by Andrew Shadura <and...@shadura.me> (Re: Bug#747048: Version 2 - patch for -nw option at boot) This is an automatic notification regarding your Bug report which was filed against the ifupdown package: #747048: ifupdown: /etc/init.d/networking Occasional long delays at boot from dhclient It has been closed by Andrew Shadura <and...@shadura.me>. Their explanation is attached below along with your original report. If this explanation is unsatisfactory and you have not received a better one in a separate message then please contact Andrew Shadura <and...@shadura.me> by replying to this email. -- 747048: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=747048 Debian Bug Tracking System Contact ow...@bugs.debian.org with problems Hello, Just to clarify: what you need is either allow-hotplug or guessnet. Both can do what you need, different ways. Do not patch the waiting away, This is wrong. -- Cheers, Andrew Package: ifupdown Version: 0.7.8 Severity: normal The dhclient program is started indirectly by ifup, called in /etc/init.d/networking. This delays boots while searching for an internet connection on occasional random boots, and possibly is related to the operation of startpar. It is caused by the timing of dhclient in the boot process, whether it starts in runlevel 1 or runlevel 2. The networking init script that starts ifup which starts dhclient runs in runlevel 1, but there is a delay before dhclient starts. The readahead-fedora package reduces this delay. If it runs in 1 then the messages written to stderr will be displayed on the console and the boot will be delayed until it has removed itself to the background, then runlevel 2 begins. In runlevel 2 the messages from runlevel 1 scripts are automatically placed in the background so no delay occurs. Output from stderr and stdout can be redirected when ifup is started. dhclient should write to a terminal when called manually via ifup to give connection information, but it is less helpful at boot, and modifying the /etc/init.d/networking script seems the most obvious solution. I am currently using this patch I wrote myself which apparently cures the delays, I have been using it for a month or so now. I wrote something similar in Debian 6 but this init script has been rewritten in 7, but still does not fix that issue. The dhclient boothang bug has been about for a few years now. It is a timing issue that may or may not appear on different systems and software configurations, and does not appear on every boot because of the random order boot scripts are run. You just need to run ifup in the background (&) and redirect stdout and stderr (>/dev/null 2>&1) to /dev/null. The extra brackets are needed to avoid syntax errors. The patch below shows the changes I made. If there was some reason you did not wish to make this change then it should serve as a helpful reference for others affected by this problem. As boots can be delayed for a minute when no internet connection is found it is inconvenient. Best wishes and happy coding! $ diff -u /opt/initbackups/networking /etc/init.d/networking --- /opt/initbackups/networking 2014-04-05 06:41:06.317019467 +0100 +++ /etc/init.d/networking 2014-04-10 22:13:03.330378114 +0100 @@ -107,7 +107,7 @@ done) if [ -n "$ifaces" ] then - ifup $ifaces "$@" || true + (ifup $ifaces "$@" >/dev/null 2>&1 &) || true fi fi } @@ -128,7 +128,7 @@ set -f exclusions=$(process_exclusions) log_action_begin_msg "Configuring network interfaces" - if ifup -a $exclusions $verbose && ifup_hotplug $exclusions $verbose + if (ifup -a $exclusions $verbose >/dev/null 2>&1 &) && (ifup_hotplug $exclusions $verbose) then log_action_end_msg $? else @@ -157,7 +157,7 @@ log_action_begin_msg "Reloading network interfaces configuration" state=$(cat /run/network/ifstate) ifdown -a --exclude=lo $verbose || true - if ifup --exclude=lo $state $verbose ; then + if (ifup --exclude=lo $state $verbose >/dev/null 2>&1 &) ; then log_action_end_msg $? else log_action_end_msg $? @@ -175,7 +175,7 @@ ifdown -a --exclude=lo $verbose || true set -f exclusions=$(process_exclusions) - if ifup -a --exclude=lo $exclusions $verbose && ifup_hotplug $exclusions $verbose + if (ifup -a --exclude=lo $exclusions $verbose >/dev/null 2>&1 &) && (ifup_hotplug $exclusions $verbose) then log_action_end_msg $? else -- System Information: Debian Release: 7.5 APT prefers stable APT policy: (500, 'stable') Architecture: i386 (i686) Kernel: Linux 3.2.0-4-486 Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages ifupdown depends on: ii dpkg 1.16.14 ii initscripts 2.88dsf-41+deb7u1 ii iproute 20120521-3+b3 ii libc6 2.13-38+deb7u1 ii lsb-base 4.1+Debian8+deb7u1 ifupdown recommends no packages. Versions of packages ifupdown suggests: ii isc-dhcp-client [dhcp-client] 4.2.2.dfsg.1-5+deb70u6 ii net-tools 1.60-24.2 pn ppp <none> pn rdnssd <none> -- Configuration Files: /etc/init.d/networking changed [not included] -- no debconf information