Skip to content

Instantly share code, notes, and snippets.

@pellekrogholt
Created March 2, 2014 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pellekrogholt/9307657 to your computer and use it in GitHub Desktop.
Save pellekrogholt/9307657 to your computer and use it in GitHub Desktop.
#!/bin/sh
mac=$1
kill_list_of_pids() {
pids=$1
# lets kill them - had to use hard `kill -9` to get it working
# and remember to send to background otherwise only first item is killed
for pid in $pids; do
kill -9 $pid > /dev/null 2> /dev/null &
done
}
kill_all_process_by_mac(){
# create at list of pids filter of the ones created by grep:
kill_list_of_pids $pids
}
kill_pingflood_device() {
pids=$(ps | grep "pingflood-*" | grep $mac | grep -v -F 'grep' | awk '{print $1}')
kill_list_of_pids $pids
}
./logger_bash kill_pids_by_mac "by mac: $mac" debug &
kill_pingflood_device
kill_all_process_by_mac
# not all are killed why ?
# because the "ash" bash version used by open-wrt do not support arrays!
# https://forum.openwrt.org/viewtopic.php?id=10824
@pellekrogholt
Copy link
Author

nb works in bash but not ash because the later one don't have arrays

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment