From owner-freebsd-current@FreeBSD.ORG Fri Jun 20 11:34:02 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 1F95337B401 for ; Fri, 20 Jun 2003 11:34:02 -0700 (PDT) Received: from master.ayalanetworks.com (d141-82-32.home.cgocable.net [24.141.82.32]) by mx1.FreeBSD.org (Postfix) with ESMTP id DE9AD43FBF for ; Fri, 20 Jun 2003 11:33:58 -0700 (PDT) (envelope-from alex@ayalanetworks.com) Received: from IT1 (fuct [24.141.82.32])h5KEWYVH061115 for ; Fri, 20 Jun 2003 14:32:35 GMT (envelope-from alex@ayalanetworks.com) From: "Alex Ayala" To: Date: Fri, 20 Jun 2003 14:35:44 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-reply-to: Subject: RE: APM problem in 5.1-RELEASE X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list 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 18:34:02 -0000 You can create a script like this: ------------------ #!/bin/sh for i in `fstat /dev/acd0 | awk '{print $3}'` do kill -9 $i #echo add deny all from any to $i >> /etc/ipfw.rules done ------------------- that will kill all processes that using acd0 Maybe that helps. aLex -----Original Message----- From: owner-freebsd-current@freebsd.org [mailto:owner-freebsd-current@freebsd.org]On Behalf Of Jesse Guardiani Sent: Friday, June 20, 2003 11:59 AM To: freebsd-current@freebsd.org Subject: Re: APM problem in 5.1-RELEASE 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 _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"