[U-Boot] [PATCH] tools/netconsole: make a bit more robust and use ncb when possible

Mike Frysinger vapier at gentoo.org
Fri Jan 9 10:38:22 CET 2009


The netcat utility likes to exit when it receives an empty packet (as it
thinks this means EOF).  This can easily occur when working with command
line editing as this behavior will be triggered when using backspace.  Or
with tabs and command line completion.  Since the local ncb util does not
have this "feature" and it supports broadcast udp, default to using that
rather than netcat.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 tools/netconsole |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/tools/netconsole b/tools/netconsole
index 09c8981..aa30d9b 100755
--- a/tools/netconsole
+++ b/tools/netconsole
@@ -31,12 +31,24 @@ if [ -z "${ip}" ] || [ -n "$3" ] ; then
 fi
 
 for nc in netcat nc ; do
-	type ${nc} >/dev/null && break
+	type ${nc} >/dev/null 2>&1 && break
 done
 
 trap "stty icanon echo intr ^C" 0 2 3 5 10 13 15
 echo "NOTE: the interrupt signal (normally ^C) has been remapped to ^T"
 
 stty -icanon -echo intr ^T
-${nc} -u -l -p ${port} < /dev/null &
-exec ${nc} -u ${ip} ${port}
+(
+if [ -x ./ncb ] ; then
+	exec ./ncb ${port}
+elif [ -x ${0%/*}/ncb ] ; then
+	exec ${0%/*}/ncb ${port}
+else
+	while ${nc} -u -l -p ${port} < /dev/null ; do
+		:
+	done
+fi
+) &
+pid=$!
+${nc} -u ${ip} ${port}
+kill $pid 2>/dev/null
-- 
1.6.1



More information about the U-Boot mailing list