APM problem in 5.1-RELEASE
Alex Ayala
alex at ayalanetworks.com
Fri Jun 20 11:34:02 PDT 2003
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 at freebsd.org
[mailto:owner-freebsd-current at freebsd.org]On Behalf Of Jesse Guardiani
Sent: Friday, June 20, 2003 11:59 AM
To: freebsd-current at 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 at freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe at freebsd.org"
More information about the freebsd-current
mailing list