From 3ed5f40df866fe48b7f634e353e40b699899c1f8 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 2 Oct 2013 18:15:07 +0200 Subject: vserver.netns: only delete the netns, if nothing is active in it --- vserver.netns | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/vserver.netns b/vserver.netns index 8d9e244..c507621 100755 --- a/vserver.netns +++ b/vserver.netns @@ -143,7 +143,19 @@ if [ -n "${_USE_NETNS}" ]; then _processSingleNetwork remove "$net" done - $_IP netns delete "$VSERVER_NAME" + procs="$($_IP netns exec "$VSERVER_NAME" netstat -tulpenW | sed '1d;2d')" + if [ -n "$procs" ]; then + echo "There are still processes active in the network namespace:" + echo "$procs" + echo + echo "Deleting of the network namespace would produce a bad state." + echo "So we DO NOT delete the network namespace. You maybe want + echo "to kill the processes and execute the following commands:" + echo " $_IP netns exec \"$VSERVER_NAME\" netstat -tulpen" + echo " $_IP netns delete \"$VSERVER_NAME\"" + else + $_IP netns delete "$VSERVER_NAME" + fi fi exit $ret -- cgit v1.2.3-1-g7c22