Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Nov 2002 22:11:24 +0700
From:      Eugene Grosbein <eugen@grosbein.pp.ru>
To:        stable@freebsd.org
Subject:   APM in STABLE: is not reenterable?
Message-ID:  <20021102221124.A252@grosbein.pp.ru>

next in thread | raw e-mail | index | archive | help
Hi!

Sometimes XFree86 4.2.0 locks console, I have not another machine at home 
and have to turn power down and up to revive machine. Certainly,
I dislike that and not only due to fsck checking my 40Gb HDD too long.
So I decided to use APM BIOS that can be set up to send USERSUSPENDREQ
when I strike power button instead of turning power down
(however, it will turn power down if I hold power button for 4 seconds).

I've already had working APM in my kernel (shutdown -p worked OK),
so I just added to /etc/rc.conf:

apmd_enable="YES"

and rewrote handling of USERSUSPENDREQ in /etc/rc.suspend.
Now it marks event in syslog, plays a melody using /dev/speaker,
makes a pause and reboots a system. A pause is used to make it possible
to cancel shutdown if the power button was striked by mistake.

It also checks if it was already started, in this case it plays another
melody and cancels shutdown. The problem is that it is NOT invoked
if power button was pressed second time. Is it indended behavour
or my BIOS's fault? 

There is a workarond: if I manually cancel shutdown, then run zzz(8),
then hit space to wake up my system, /etc/rc.suspend WILL be invoked
next time power will be pressed. But workaround is ugly and
if I forget to apply it, I may be forced to perform dirty reboot
if X will lock.

My system has Iwill 440BX BD100+ motherboard with latest Award BIOS 4.51
supplied by Iwill. Here is my /etc/rc.suspend:

#!/bin/sh

logger -t apmd suspend at `date +'%Y%m%d %H:%M:%S'`

if [ -r /var/run/rc.suspend.pid ]; then
	# Cancel shutdown
        kill `cat /var/run/rc.suspend.pid` 2>/dev/null
        killall shutdown 2>/dev/null
	rm -f /var/run/nologin
        echo T250L4CG >/dev/speaker
        logger -t apmd SHUTDOWN canceled
        rm -f /var/run/rc.suspend.pid
        exit 0
fi

# Prepare to shutdown: play melody, wait 15 seconds, 
# play another melody, invoke shutdown -r +1

sh -c '
echo $$ > /var/run/rc.suspend.pid
logger -t apmd SHUTDOWN planned
echo T250L8CE-GE-C >/dev/speaker
apm -e disable
apm -e enable
sleep 15
echo T250L16B+BA+AG+GF+FED+DC+CC >/dev/speaker
shutdown -r +1
rm -f /var/run/rc.suspend.pid' &
exit 0

# EOF

Why does not apmd(8) obtain second USERSUSPENDREQ ?
How can I know if a kernel masks it or BIOS suppresses it?

Eugene Grosbein

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021102221124.A252>