Skip to content

Commit

Permalink
app-emulation/lxc: Improve init script for shutting down containers. …
Browse files Browse the repository at this point in the history
…Bug #556826

Package-Manager: portage-2.2.20.1
  • Loading branch information
Markos Chandras committed Sep 5, 2015
1 parent 4e8ca1d commit 47806fd
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions app-emulation/lxc/files/lxc.initd.3
Original file line number Diff line number Diff line change
Expand Up @@ -111,29 +111,8 @@ stop() {
return 0
fi

init_pid=$(lxc-info -n ${CONTAINER} --pid | awk '{ print $2 }')

if [ -z "${init_pid}" ]; then
ewarn "${CONTAINER} doesn't seem to be running."
return 0
fi

ebegin "Shutting down system in ${CONTAINER}"
kill -PWR ${init_pid}
eend $?

TIMEOUT=${TIMEOUT:-30}
i=0
while [ -n "$(pgrep -P ${init_pid})" -a $i -lt ${TIMEOUT} ]; do
sleep 1
i=$(expr $i + 1)
done

if [ -n "${missingprocs}" ]; then
ewarn "Something failed to properly shut down in ${CONTAINER}"
fi

# 10s should be enough to shut everything down
ebegin "Stopping ${CONTAINER}"
lxc-stop -n ${CONTAINER}
lxc-stop -t 10 -n ${CONTAINER}
eend $?
}

0 comments on commit 47806fd

Please sign in to comment.