Skip to content

Commit

Permalink
Merge pull request #78 from xiaods/xiaods-patch-1
Browse files Browse the repository at this point in the history
fix stop-k8e.sh bug
  • Loading branch information
xiaods authored Apr 26, 2021
2 parents 506a420 + 6ee455c commit 6dbf84e
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions contrib/stop-k8e.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,14 @@
#!/bin/sh
set -e

echo "stop k8e process"


pschildren() {
ps -e -o ppid= -o pid= | \
sed -e 's/^\s*//g; s/\s\s*/\t/g;' | \
grep -w "^$1" | \
cut -f2
}
pstree() {
for pid in $@; do
echo $pid
for child in $(pschildren $pid); do
pstree $child
done
done
}

killtree() {
kill -9 $(
{ set +x; } 2>/dev/null;
pstree $@;
set -x;
) 2>/dev/null
kill -9 $@ 2>/dev/null
}

getshims() {
ps axu|grep k8e|grep -v grep|awk '{print $2}'
ps axu|grep k8e|grep -v grep|grep -v containerd|awk '{print $2}'
}

killtree $({ set +x; } 2>/dev/null; getshims; set -x)

0 comments on commit 6dbf84e

Please sign in to comment.