From owner-freebsd-current@FreeBSD.ORG Fri Jun 20 09:03:18 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1998437B401 for ; Fri, 20 Jun 2003 09:03:18 -0700 (PDT) Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by mx1.FreeBSD.org (Postfix) with ESMTP id B27EE43F93 for ; Fri, 20 Jun 2003 09:03:16 -0700 (PDT) (envelope-from freebsd-current@m.gmane.org) Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 19TOKs-0003pD-00 for ; Fri, 20 Jun 2003 18:01:58 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-current@freebsd.org Received: from news by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 19TOHc-0003am-00 for ; Fri, 20 Jun 2003 17:58:36 +0200 From: Jesse Guardiani Date: Fri, 20 Jun 2003 11:58:42 -0400 Organization: WingNET Lines: 182 Message-ID: References: <200306191916.MAA15640@mina.soco.agilent.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: usenet@main.gmane.org User-Agent: KNode/0.7.2 X-Mail-Copies-To: never Sender: news Subject: Re: APM problem in 5.1-RELEASE X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: jesse@wingnet.net List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jun 2003 16:03:18 -0000 Jesse Guardiani wrote: > Things I would like to improve upon: > ------------------------------------ > 1.) I need to find some way to automatically kill any processes that are > using (or have opened) the /dev/acd0 device BEFORE executing apm -z > from /etc/rc.suspend. OK. The following pipeline does a pretty good job of this: # Kill any process currently using /dev/acd0 kill -KILL `fstat /dev/acd0 | sed -Ee 's/[[:space:]]+/ /g' | cut -d ' ' -f 3` It isn't perfect (i.e. if more than one process has /dev/acd0 open, it won't kill the second process), but I can expand on this to make it fit just about any need. [...] > 2.) I'd love to automate (or do away with) the process of switching to > a VTY from X before executing 'atacontrol detach 1'. This from Tobias Roth: ------------------------------------------------------------------------- to do this automatically, change your /etc/rc.suspend and /etc/rc.resume like this: /etc.rc.suspend: insert this line just before the 'logger' line: vidcontrol -s 2 < /dev/ttyv0 /etc/rc.resume: insert this line just before the 'logger' line: vidcontrol -s 1 < /dev/ttyv0 ------------------------------------------------------------------------- This works pretty darn well! Thanks Tobias! I can now suspend my machine from X without fear of kernel panic! Thanks for the help everyone! Here is my rc.suspend, just in case someone else with an IBM Thinkpad A30p needs it: ---------- /etc/rc.suspend ---------- #!/bin/sh # # Copyright (c) 1999 Mitsuru IWASAKI # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD: src/etc/rc.suspend,v 1.4 2000/10/08 19:18:24 obrien Exp $ # # sample run command file for APM Suspend Event if [ -r /var/run/rc.suspend.pid ]; then exit 1 fi echo $$ > /var/run/rc.suspend.pid # If you have troubles on suspending with PC-CARD modem, try this. # See also contrib/pccardq.c (Only for PAO users). # pccardq | awk -F '~' '$5 == "filled" && $4 ~ /sio/ \ # { printf("pccardc power %d 0", $1); }' | sh logger -t apmd suspend at `date +'%Y%m%d %H:%M:%S'` # Kill any process currently using /dev/acd0 kill -KILL `fstat /dev/acd0 | sed -Ee 's/[[:space:]]+/ /g' | cut -d ' ' -f 3` # switch to a TTY vidcontrol -s 1 < /dev/ttyv0 # detach buggy CD-ROM before suspending. sync && sync && sync atacontrol detach 1 sleep 1 sync && sync && sync sleep 1 rm -f /var/run/rc.suspend.pid zzz exit 0 ---------- end /etc/rc.suspend ---------- And here is my /etc/rc.resume: ---------- /etc/rc.resume ---------- #!/bin/sh # # Copyright (c) 1999 Mitsuru IWASAKI # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD: src/etc/rc.resume,v 1.5 2000/12/17 08:15:57 dougb Exp $ # # sample run command file for APM Resume Event if [ -r /var/run/rc.suspend.pid ]; then kill -9 `cat /var/run/rc.suspend.pid` rm -f /var/run/rc.suspend.pid echo 'rc.suspend is killed' fi # Turns on a power supply of a card in the slot inactivated. # See also contrib/pccardq.c (only for PAO users). # pccardq | awk -F '~' '$5 == "inactive" \ # { printf("pccardc power %d 1", $1); }' | sh # Switch back to X vidcontrol -s 9 < /dev/ttyv0 logger -t apmd resumed at `date +'%Y%m%d %H:%M:%S'` sync && sync && sync # Reattach and reinitialize ATA channel 1 atacontrol attach 1 exit 0 ---------- end /etc/rc.resume ---------- -- Jesse Guardiani, Systems Administrator WingNET Internet Services, P.O. Box 2605 // Cleveland, TN 37320-2605 423-559-LINK (v) 423-559-5145 (f) http://www.wingnet.net