From 17e7247f28975f7bee182bc4d21830a5132bfc9a Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 16 Apr 2008 14:29:01 +0000 Subject: [PATCH] pwmconfig: Don't start if fancontrol is running. fancontrol: Don't start if already running, delete fancontrol.pid at exit time. This closes ticket #2299. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5180 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 3 +++ prog/init/fancontrol.init | 1 - prog/pwm/fancontrol | 12 ++++++++++-- prog/pwm/pwmconfig | 12 ++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 43014dc5..3be60a30 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,9 @@ SVN-HEAD pwmconfig: Don't create the configuration file before it's needed Don't preserve configuration file customizations Fix permissions of the configuration file + Don't start if fancontrol is running (#2299) + fancontrol: Don't start if already running (#2299) + Delete fancontrol.pid at exit time (#2299) sensors-detect: Add SMSC SCH5027D detection Do not access I/O ports on PPC Move south bridge sensor detection to the right section diff --git a/prog/init/fancontrol.init b/prog/init/fancontrol.init index 38fce8e4..eabe734c 100755 --- a/prog/init/fancontrol.init +++ b/prog/init/fancontrol.init @@ -34,7 +34,6 @@ stop() echo -n "Stopping fancontrol daemon" killproc $FANCONTROL RETVAL=$? - rm -f $PIDFILE rm -f /var/lock/subsys/fancontrol echo } diff --git a/prog/pwm/fancontrol b/prog/pwm/fancontrol index 23281f73..04498755 100755 --- a/prog/pwm/fancontrol +++ b/prog/pwm/fancontrol @@ -22,7 +22,7 @@ # # # Copyright 2003 Marius Reiner -# Copyright (C) 2007 Jean Delvare +# Copyright (C) 2007-2008 Jean Delvare # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -41,10 +41,17 @@ # # +PIDFILE="/var/run/fancontrol.pid" + #DEBUG=1 MAX=255 -echo $$ > /var/run/fancontrol.pid +if [ -f "$PIDFILE" ] +then + echo "File $PIDFILE exists, is fancontrol already running?" + exit 1 +fi +echo $$ > "$PIDFILE" declare -i pwmval @@ -248,6 +255,7 @@ function restorefans() let fcvcount=$fcvcount+1 done echo 'Verify fans have returned to full speed' + rm -f "$PIDFILE" exit $status } diff --git a/prog/pwm/pwmconfig b/prog/pwm/pwmconfig index 820c6d20..61823f24 100755 --- a/prog/pwm/pwmconfig +++ b/prog/pwm/pwmconfig @@ -27,6 +27,18 @@ # MA 02110-1301 USA. # # + +PIDFILE="/var/run/fancontrol.pid" + +if [ -f "$PIDFILE" ] +then + echo "File $PIDFILE exists. This typically means that the" + echo "fancontrol deamon is running. You should stop it before running pwmconfig." + echo "If you are certain that fancontrol is not running, then you can delete" + echo "$PIDFILE manually." + exit 1 +fi + echo 'This program will search your sensors for pulse width modulation (pwm)' echo 'controls, and test each one to see if it controls a fan on' echo 'your motherboard. Note that many motherboards do not have pwm'