From owner-freebsd-stable Sat Nov 2 7:15:38 2002 Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DB0D437B401 for ; Sat, 2 Nov 2002 07:15:35 -0800 (PST) Received: from grosbein.pp.ru (www2.svzserv.kemerovo.su [213.184.65.86]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9481543E42 for ; Sat, 2 Nov 2002 07:15:29 -0800 (PST) (envelope-from eugen@grosbein.pp.ru) Received: from grosbein.pp.ru (smmsp@localhost [127.0.0.1]) by grosbein.pp.ru (8.12.6/8.12.5) with ESMTP id gA2FFB0X000421 for ; Sat, 2 Nov 2002 22:15:11 +0700 (KRAT) (envelope-from eugen@grosbein.pp.ru) Received: (from eugen@localhost) by grosbein.pp.ru (8.12.6/8.12.6/Submit) id gA2FBOik000378 for stable@freebsd.org; Sat, 2 Nov 2002 22:11:24 +0700 (KRAT) Date: Sat, 2 Nov 2002 22:11:24 +0700 From: Eugene Grosbein To: stable@freebsd.org Subject: APM in STABLE: is not reenterable? Message-ID: <20021102221124.A252@grosbein.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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