gsmd: Adjust the oom score of the monitor process

Adjust the score for the monitor process. The issue is that the
score is inherited by the process. Right now the score of the
child is adjusted _after_ the process has been spawned. This is
obviously a race condition.
This commit is contained in:
Holger Hans Peter Freyther 2013-03-15 23:21:22 +01:00
parent 90d152fcff
commit 3e7dbdcdba
1 changed files with 5 additions and 1 deletions

View File

@ -4,13 +4,17 @@ NAME=`basename $1`
PIDFILE="/var/run/$NAME.pid"
PID=$$
echo "$PID" > $PIDFILE
echo "-1000" > /proc/$PID/oom_score_adj
trap "{ rm -f $PIDFILE ; kill 0; }" EXIT
while true;
do
echo "Restarting not dealing well with spaces.."
(exec $*) || true
exec $* &
LAST_PID=$!
echo "0" > /proc/$LAST_PID/oom_score_adj
wait $LAST_PID
sleep 10s
done