summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-09-09 12:20:20 -0400
committerTom Rix <Tom.Rix@windriver.com>2009-10-03 09:04:26 -0500
commit9914be9dee28adf70dbfceeb62ec51d23ce096fc (patch)
tree8c7d1a8e9a1f06e9c9f3d41bbf0219eabd22d0b7
parent85c735f9a57f0694266ffea00a4d5f8f4e2bacda (diff)
tools/netconsole: make a bit more robust
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. So create two netcat processes - one to only listen (and put it into a loop), and one to do the sending. Once the user quits the transmitting netcat, the listening one will be killed automatically. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rwxr-xr-xtools/netconsole12
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/netconsole b/tools/netconsole
index 09c8981682..6ef2723f58 100755
--- a/tools/netconsole
+++ b/tools/netconsole
@@ -31,12 +31,18 @@ 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}
+(
+while ${nc} -u -l -p ${port} < /dev/null ; do
+ :
+done
+) &
+pid=$!
+${nc} -u ${ip} ${port}
+kill ${pid} 2>/dev/null