Commit 9914be9d authored by Mike Frysinger's avatar Mike Frysinger Committed by Tom Rix

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: default avatarMike Frysinger <vapier@gentoo.org>
parent 85c735f9
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment