Changeset 4439

Show
Ignore:
Timestamp:
06/12/07 13:26:11 (6 years ago)
Author:
khali
Message:

fancontrol: Better integration with init scripts (picked from Suse)
* Do not return with an error when receiving SIGTERM.
* Handle signals while sleeping.

Location:
lm-sensors/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/CHANGES

    r4438 r4439  
    2020                      Check for configuration file validity 
    2121                      Support optional min and max PWM values 
     22                      Better integration with init scripts 
    2223  Program pwmconfig: Use smaller steps for low PWM values 
    2324                     Support optional min and max PWM values 
  • lm-sensors/trunk/prog/pwm/fancontrol

    r4438 r4439  
    229229function restorefans() 
    230230{ 
     231        local status=$1 
    231232        echo 'Aborting, restoring fans...' 
    232233        let fcvcount=0 
     
    238239        done 
    239240        echo 'Verify fans have returned to full speed' 
    240         exit 1 
    241 } 
    242  
    243 trap restorefans SIGHUP SIGINT SIGQUIT SIGTERM SIGKILL 
     241        exit $status 
     242} 
     243 
     244trap 'restorefans 0' SIGQUIT SIGTERM 
     245trap 'restorefans 1' SIGHUP SIGINT 
    244246 
    245247# main function 
     
    263265                then 
    264266                        echo "Error reading temperature from $DIR/$tsens" 
    265                         restorefans 
     267                        restorefans 1 
    266268                fi 
    267269                if [ "$SYSFS" = "1" ] 
     
    276278                then 
    277279                        echo "Error reading PWM value from $DIR/$pwmo" 
    278                         restorefans 
     280                        restorefans 1 
    279281                fi 
    280282                if [ "$SYSFS" != "1" ] 
     
    290292                        then 
    291293                                echo "Error reading Fan value from $DIR/$fan" 
    292                                 restorefans 
     294                                restorefans 1 
    293295                        fi 
    294296                        if [ "$SYSFS" != "1" ] 
     
    327329                  then # if fan was stopped start it using a safe value 
    328330                        echo $minsa > $pwmo 
    329                         sleep 1 
     331                        # Sleep while still handling signals 
     332                        read < <(exec sleep 1) 
    330333                  fi 
    331334                fi 
     
    334337                then 
    335338                        echo "Error writing PWM value to $DIR/$pwmo" 
    336                         restorefans 
     339                        restorefans 1 
    337340                fi 
    338341                if [ "$DEBUG" != "" ] 
     
    353356        then 
    354357                echo "Error enabling PWM on $DIR/$pwmo" 
    355                 restorefans 
     358                restorefans 1 
    356359        fi 
    357360        let fcvcount=$fcvcount+1 
     
    364367do 
    365368        UpdateFanSpeeds 
    366         sleep $INTERVAL 
     369        # Sleep while still handling signals 
     370        read < <(exec sleep $INTERVAL) 
    367371done