summaryrefslogtreecommitdiff
path: root/samples/pktgen/pktgen_sample01_simple.sh
diff options
context:
space:
mode:
Diffstat (limited to 'samples/pktgen/pktgen_sample01_simple.sh')
-rwxr-xr-xsamples/pktgen/pktgen_sample01_simple.sh13
1 files changed, 10 insertions, 3 deletions
diff --git a/samples/pktgen/pktgen_sample01_simple.sh b/samples/pktgen/pktgen_sample01_simple.sh
index 246cfe02bb82..09a92ea963f9 100755
--- a/samples/pktgen/pktgen_sample01_simple.sh
+++ b/samples/pktgen/pktgen_sample01_simple.sh
@@ -79,15 +79,22 @@ pg_set $DEV "flag UDPSRC_RND"
pg_set $DEV "udp_src_min $UDP_SRC_MIN"
pg_set $DEV "udp_src_max $UDP_SRC_MAX"
+# Run if user hits control-c
+function print_result() {
+ # Print results
+ echo "Result device: $DEV"
+ cat /proc/net/pktgen/$DEV
+}
+# trap keyboard interrupt (Ctrl-C)
+trap true SIGINT
+
if [ -z "$APPEND" ]; then
# start_run
echo "Running... ctrl^C to stop" >&2
pg_ctrl "start"
echo "Done" >&2
- # Print results
- echo "Result device: $DEV"
- cat /proc/net/pktgen/$DEV
+ print_result
else
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
fi \ No newline at end of file