mcstop: add -k to kill processses using /dev/mcos* before shutdown
Use lsof to check for processes that still open /dev/mcosX at shutdown time. If lsof is not installed then the check is just not done (empty PROCS result) If -k is not passed, print a message listing pids of users and exit (taking bets someone will use that and sed to kill out of mcstop+release and rerun the stop script instead of passing -k at some point) Change-Id: Idba7486fdede4990d9885d23f8077f33839daeed
This commit is contained in:
committed by
Dominique Martinet
parent
21c9e57646
commit
c96dfb0c68
@ -18,6 +18,23 @@ KERNDIR="@KERNDIR@"
|
||||
mem=""
|
||||
cpus=""
|
||||
irqbalance_used=""
|
||||
kill_in_use=""
|
||||
|
||||
while getopts k OPT
|
||||
do
|
||||
case ${OPT} in
|
||||
k)
|
||||
kill_in_use=1
|
||||
;;
|
||||
\?) exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [[ "$#" -ge "$OPTIND" ]]; then
|
||||
shift $((OPTIND - 1))
|
||||
echo "Extra arguments: $@" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
disable_irqbalance_mck() {
|
||||
if [ -f /etc/systemd/system/irqbalance_mck.service ]; then
|
||||
@ -43,6 +60,18 @@ fi
|
||||
if ls /dev/mcos* 1>/dev/null 2>&1; then
|
||||
for i in /dev/mcos*; do
|
||||
ind=`echo $i|cut -c10-`;
|
||||
|
||||
# Are processes still using it?
|
||||
PROCS=$(lsof -t $i 2>/dev/null)
|
||||
if [[ -n "$PROCS" ]]; then
|
||||
if ((kill_in_use)); then
|
||||
kill -9 $PROCS
|
||||
else
|
||||
echo "Proesses still using $i: $PROCS" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Retry when conflicting with ihkmond
|
||||
nretry=0
|
||||
until ${SBINDIR}/ihkconfig 0 destroy $ind || [ $nretry -ge 4 ]; do
|
||||
|
||||
Reference in New Issue
Block a user