Automatically stop nVidia graphics even if the application script nvrun gets SIGTERM signal.
This commit is contained in:
parent
f5ccd68db6
commit
a44e4e2e87
|
@ -14,7 +14,9 @@ start() {
|
|||
! ps -p `cat $PIDFILE 2>&1` > /dev/null 2>&1 || eend -1
|
||||
export LD_LIBRARY_PATH=/usr/lib/opengl/nvidia/lib:/usr/lib/opengl/nvidia/lib
|
||||
start-stop-daemon --start --quiet --background --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS
|
||||
eend $?
|
||||
status=$?
|
||||
(snail.autostop &>/dev/null)&
|
||||
eend $status
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
LOCK_FILE=/tmp/.snail.nvrun.lock
|
||||
NVRUN=/usr/local/bin/nvrun
|
||||
|
||||
(
|
||||
flock -n 9
|
||||
for i in `seq 8`; do
|
||||
flock -n 9
|
||||
|
||||
if [ 0 -ne $? ]; then
|
||||
echo "Cann't lock $COUNT_FILE. Exiting..."
|
||||
exit -1
|
||||
fi
|
||||
if [[ 0 -ne $? && 5 -eq $i ]]; then
|
||||
echo "Cann't lock $COUNT_FILE. Exiting..."
|
||||
exit -1
|
||||
|
||||
elif [ 0 -eq $? ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
snail.nvstat || snail.nvon
|
||||
|
||||
|
@ -22,14 +30,21 @@ LOCK_FILE=/tmp/.snail.nvrun.lock
|
|||
snail.nvrun "$@"
|
||||
|
||||
(
|
||||
flock -n 9
|
||||
for i in `seq 8`; do
|
||||
flock -n 9
|
||||
|
||||
if [ 0 -ne $? ]; then
|
||||
echo "Cann't lock $COUNT_FILE. Exiting..."
|
||||
exit -1
|
||||
fi
|
||||
if [[ 0 -ne $? && 5 -eq $i ]]; then
|
||||
echo "Cann't lock $COUNT_FILE. Exiting..."
|
||||
exit -1
|
||||
|
||||
pgrep snail.nvrun &>/dev/null
|
||||
elif [ 0 -eq $? ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
pgrep -f $NVRUN &>/dev/null
|
||||
|
||||
if [ 0 -eq $? ]; then
|
||||
echo "Other applications still use nVidia chip. So we aren't switching off it, just exiting..."
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/sh
|
||||
|
||||
LOCK_FILE=/tmp/.snail.nvrun.lock
|
||||
NVRUN=/usr/local/bin/nvrun
|
||||
|
||||
while [ 1 ]; do
|
||||
pgrep -f $NVRUN &>/dev/null
|
||||
|
||||
if [ 0 -ne $? ]; then
|
||||
|
||||
(
|
||||
for i in `seq 16`; do
|
||||
flock -n 9
|
||||
|
||||
if [[ 0 -ne $? && 5 -eq $i ]]; then
|
||||
echo "Cann't lock $COUNT_FILE. Exiting..."
|
||||
exit -1
|
||||
|
||||
elif [ 0 -eq $? ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
snail.nvoff
|
||||
[ 0 -ne $? ] && echo "Error: Cann't switch off nVidia graphics. Exiting..." && exit -1
|
||||
echo "nVidia chip powered off."
|
||||
exit 0
|
||||
) 9>$LOCK_FILE ; exit $?
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
Loading…
Reference in New Issue