Off-button reaction time

EdorFaus edorfaus at xepher.net
Tue Aug 16 15:08:22 EDT 2011


Hi,

Like some others, I've noticed that it appears to take a few seconds 
from you hit the power button until the NanoNote turns off.

Reading about it suggested to me that this was only apparent, that it 
immediately runs poweroff, just doesn't appear to react because gmenu2x 
doesn't display in any way that the device is shutting down.

I figured it would help a bit if gmenu2x shut down immediately, because 
at least then you can see that the device reacted to the button press, 
and is in fact powering down.

So, I created a new init.d script that, in its stop() function, simply 
runs "killall gmenu2x", and enabled it as one of the first things to be 
run on shutdown (STOP=01) - but this only worked sometimes, not always.

I eventually found out that the problem is the script that starts the 
actual gmenu2x program; if that is killed before the actual program is, 
it fails to stop (and indeed stops reacting at all). Since it has the 
same name as the real program, killall kills both - usually the script 
first, since that has the smaller PID.

I then tried exec-ing the real executable from the script, but that made 
it not work at all - init just kept restarting the script.

I tried several things to get around this, eventually ending up with 
trapping the HUP signal in the script before exec-ing the real program, 
which for some unknown reason works - I don't really see where the HUP 
is coming from; tests with a custom program that traps SIGHUP fail 
because that program isn't getting one...

Anyway, I've ended up with a solution that works - when I hit the power 
button, or run "reboot" in an ssh shell, gmenu2x immediately disappears, 
showing that the device is doing something (shutting down).

As a side-effect, I'm left with one less process running on the device, 
not that I think it matters much (since it's just a busybox ash). :)

I've attached the init.d script and the patched /usr/bin/gmenu2x (since 
it's smaller than the .patch), in case anyone wants to use it.

-- 
Regards,
Frode
-------------- next part --------------
#!/bin/sh

source /etc/profile

#setfont2 /usr/share/setfont2/un-fuzzy-6x10-font.pnm
#loadunimap /usr/share/setfont2/ben_uni.trans

setfont  /usr/share/kbd/consolefonts/kernel-6x11-font

trap "" hup

clear
cd /usr/share/gmenu2x && exec ./gmenu2x
-------------- next part --------------
#!/bin/sh /etc/rc.common
# Copyright (C) 2011 OpenWrt.org, Frode Austvik

STOP=01

start() {
	return 0
}

stop() {
	killall gmenu2x
	return 0
}


More information about the discussion mailing list


interactive