[ltp] fancontrol script: Interrupted system call
Henrique de Moraes Holschuh
linux-thinkpad@linux-thinkpad.org
Thu, 11 Oct 2007 18:14:24 -0300
On Thu, 11 Oct 2007, Henrique de Moraes Holschuh wrote:
> On Thu, 11 Oct 2007, Richard Neill wrote:
> > Henrique de Moraes Holschuh wrote:
> >>> /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?
> >
> > I was lead to believe that the read() and write() system calls used to be
> > interruptable (with EINTR), but as of some time ago, glibc was re-written
> > such that the syscall itself would handle restarting interrupted calls, and
> > the main program would never see EINTR.
>
> It could actually be my fault as well. Am I supposed to return EINTR inside
> the kernel, or ERESTARTSYS (which doesn't make it to userspace) ? Since
> the locking primitives return EINTR, that's exactly what I am returning to
> the sysfs core.
>
> Still, if userspace gets an EINTR, it has to either retry, or do something
> smart for a error that is known to always be transient.
Ok, I asked around, and I can make things a little better for userspace
error handling if I try to return ERESTARTSYS* if a signal is pending. I
will try that. The kernel will resubmit the syscall by itself, then, which
is usually enough for EINTR to never be issued. If it can't resubmit, it
will return EINTR.
--
"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