[ltp] fancontrol script: Interrupted system call

Henrique de Moraes Holschuh linux-thinkpad@linux-thinkpad.org
Thu, 11 Oct 2007 14:43:25 -0300


On Thu, 11 Oct 2007, Peter Jordan wrote:
> I hope it`s the right place to post my problem.
> 
> I wrote a fancontrol script for my thinkpad r60. the script works well
> but sometimes after a while (2 minutes or 12 hours) the script crashes
> with the following error:
> 
> /usr/sbin/fancontrol: line 50: echo: write error: Interrupted system
> call
> 
> line 50 of the script:
> 
> echo $speed > /sys/devices/platform/thinkpad_hwmon/pwm1
> 
> Can someone help me?

When you get an EINTR (interrupted system call), retry the operation.  This
is needed for *every* read/write operation.  I wonder why the !@#$ shell is
not doing it by itself?

Granted, libsensors has the same problem. Oh well.

You *will* get EINTRs sooner or later, it happens if a process receives a
signal of some sort while in kernel space.  Not everything that implements
sysfs returns EINTRs, but normal file IO does, and so does thinkpad-acpi
sysfs.

Doing this should be enough for most scenarios where an EINTR happens:

echo $speed > /sys/devices/platform/thinkpad_hwmon/pwm1 || echo $speed >
/sys/devices/platform/thinkpad_hwmon/pwm1 || <error stuff goes here>

i.e. try it twice in a row.  And then, do whatever you must in an error
situation.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh