[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev Problem with ^Z suspending - ugly linux bash hack
From: |
Klaus Weide |
Subject: |
lynx-dev Problem with ^Z suspending - ugly linux bash hack |
Date: |
Sat, 30 Jan 1999 05:12:36 -0600 (CST) |
I mentioned earlier in this thread that a shell script could do
something to prevent the problems from occurring - for completeness,
here is an example.
This is completely linux- and bash-dependent, probably specific versions;
I don't recommend that anyone actually use it. Certainly not if
you can't risk screwed up tty settings, hung processes, or being
arbitrarily logged out. :)
It just happens to prevent problems I, II, III when suspending it on
my system.
Klaus
---------------- snip ---------------
#!/bin/bash
stopping=
tstpwaiting ()
{
local tty=$(tty)
if [ "$tty" = "not a tty" ]; then
tty=$(tty 0<&2)
fi
if [ "$tty" = "not a tty" ]; then
tty=$(tty 0</dev/tty)
fi
if [ "$tty" = "not a tty" ]; then
tty=/dev/tty
fi
"$@" <$tty &
local child=$!
trap "cycle_till_stopped \$child" 20
trap "stty sane" 2
wait $child
local rc=$?
trap 2
echo after wait, tstpwaiting "$@" returns $rc.
return $rc
}
cycle_till_stopped ()
{
if [ $stopping ]; then
kill -STOP $$
return 0
fi
trap "" 20
stopping=1
local child=$1
{ read && read a STAT d; } </proc/$child/status
test $? != 0 && exit
while [ "$STAT" != "T" ]; do
usleep 50000 # replace with 'sleep 1' if there is no usleep command
{ read && read a STAT d; } </proc/$child/status
test $? != 0 && exit
done
kill -STOP $$
local rc=$?
stopping=""
trap "cycle_till_stopped \$child" 20
return $rc
}
# finally we're ready to do something - invoke an interactive,
# curses using program. Just prefix the usual command line
# with "tstpwaiting".
tstpwaiting /usr/local/src/lynx2-8-2/src/lynx -show_cursor http://localhost
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lynx-dev Problem with ^Z suspending - ugly linux bash hack,
Klaus Weide <=