summaryrefslogtreecommitdiff
path: root/test_bandwidth_limit
blob: 8669768843e6e09b0baad9b44777751895ab9630 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/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"