#!/bin/bash # Doesn't actually work but gives a usage example if [ "x$1" == "xpv" ]; then nc -l 15000 | pv > /dev/null exit 0 fi if [ "x$1" == "xcat" ]; then cat /dev/zero | nc localhost 13300 exit 0 fi gnome-terminal --geometry 80x5 -e "./test_bandwidth_limit pv" PID1=$! echo PID1 = $PID1 # --bandwidth-limit 1024 ./bandwidthmon --listen-port 13300 --remote-port 15000 --bandwidth-limit 1024 & PID2=$! sleep 1 gnome-terminal --geometry 80x3 -e "./test_bandwidth_limit cat" PID3=$! echo PID3 = $PID3 function sigint { echo "SIGINT caught" if [ "x$PID1" != "x" ]; then kill $PID1 fi kill $PID2 kill $PID3 } # SIGINT trap sigint SIGINT wait echo "all processes exited"