[laptop-mode] [PATCH] Laptop mode hangs indefinately when battery polling is used
Matthijs Kooijman
matthijs at stdin.nl
Sun Jul 12 16:35:07 CEST 2009
--rltfBdJX5ToILDSK
Content-Type: multipart/mixed; boundary="KvB7u8NuoXBZIbZd"
Content-Disposition: inline
--KvB7u8NuoXBZIbZd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hi,
I've encountered symptoms of the same issue reported a while back ("unable =
to
stop LM while on battery"), located the problem and found a fix for it.
The problem I was facing, was that laptop-mode sometimes hangs indefinately=
on
startup. Initially I suspected a kernel upgrade, but it turns out the batte=
ry
polling module is responsible for this. Since the battery polling is not
started when on AC, and I usually boot on AC (and do dehibernation on the
road), I hadn't noticed this issue before.
What happens is actually really simple: /etc/init.d/laptopmode starts
laptop-mode, but captures its output like this:
RESULT=3D`/usr/sbin/laptop_mode init auto`
Somewhere during it's run, laptop_mode calls
/usr/share/laptop-mode-tools/modules/battery-level-polling, which again cal=
ls
the lm-polling-daemon helper:
/usr/share/laptop-mode-tools/module-helpers/lm-polling-daemon &
However, this daemon is just backgrounded with &, but it's stdout is still
connected, meaning that RESULT=3D`` line will wait for the polling daemon to
quit before returning (i.e., never). This was particularly nasty to find,
since the laptop_mode script itself of course continues as normal, all the =
way
to its end, and only then execution hangs.
To fix this, we should disconnect at least stdout from the polling daemon, =
but
disconnecting all file descriptors is probably better. e.g.:=20
/usr/share/laptop-mode-tools/module-helpers/lm-polling-daemon \=20
< /dev/null > /dev/null 2> /dev/null &
Also see the attached (trivial) patch, which fixes the issue. Since this is=
sue
can prevent systems from booting and shutting down, I hope this will be fix=
ed
soon!
Gr.
Matthijs
--KvB7u8NuoXBZIbZd
Content-Disposition: attachment; filename="battery-polling.diff"
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
A non-text attachment was scrubbed...
Name: battery-polling.diff
Type: text/x-diff
Size: 522 bytes
Desc: not available
URL: <http://mailman.samwel.tk/pipermail/laptop-mode/attachments/20090712/4df10626/attachment.diff>
--KvB7u8NuoXBZIbZd--
--rltfBdJX5ToILDSK
Content-Description: Digital signature
Content-Disposition: inline
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://mailman.samwel.tk/pipermail/laptop-mode/attachments/20090712/4df10626/attachment.pgp>
--rltfBdJX5ToILDSK--
More information about the laptop-mode
mailing list