home *** CD-ROM | disk | FTP | other *** search
- :
- # NAME
- # vmailicon - set the icon for /dev/tty's window
- #
- # SYNOPSIS
- # vmailicon iconfile
- #
- # DESCRIPTION
- # This is the tool that vmailtool uses to raise or lower the icon
- # flag. This tool exists because the method used to set the icon
- # (echoing a shelltool "terminal" command string to /dev/tty)
- # sometimes blocks forever due to a race condition. This tool can
- # keep trying to set the icon until it finally succeeds, and it
- # can do it in the background so vmailtool doesn't hang up.
- #
- # AUTHOR
- # James Perkins 6 Feb 1991
-
- case $# in
- 1) icon=$1;;
- *) echo "usage: $0 iconfile" >&2; exit 1;;
- esac
-
- if [ ! -f $icon ]
- then
- echo "usage: $0 iconfile" >&2
- exit 1
- fi
-
- # run echo and then kill it. If the echo is finished, the kill will return a
- # nonzero exit code. If the kill succeeds, the echo wasn't finished, so
- # loop back and try again, ad nauseum. Give up after maxtries tries.
-
- export iconfile
- (
- trynum=1
- maxtries=5
- status=0
- while [ $status -eq 0 -a $trynum -le $maxtries ]
- do
- echo -n "]I${icon}\\" >/dev/tty &
- echopid=$!
- trynum=`expr $trynum + 1`
- sleep 1
- kill -9 $! > /dev/null 2>&1
- status=$?
- done
-
- if [ $trynum -gt $maxtries ]
- then
- echo "vmailicon: icon not set after $trynum tries" >&2
- fi
- ) &
-