Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RE: checking jobs when zsh exits



Alan
	Good suggestion.... I have a hackish way of doing this (below) but it would
be nice if there was a better way.

	Also, fyi, the zsh-user@xxxxxxxxxxxxxxx address is obsolete...
unfortunately I don't have the new one, but I think you can find it at
www.zsh.org

	Here's my hack-script, which I call "jobout" and then have:

alias x='source jobout'

	and so when I want to logout I just type 'x' and it tells me if I have any
jobs or not.

		TjL



# RHOST is a variable I have setup based on
#  	who am i |awk '{print $NF}'|tr -d '(|)'

jobsfile=/tmp/jobs.$tty.$USER

/bin/rm -f $jobsfile

jobs -l 1>& $jobsfile

COUNT=`wc -l $jobsfile | awk '{print $1}'`

if [ "$COUNT" != "0" ]
then
        echo "This tty has stopped jobs:"
        cat $jobsfile
        /bin/rm -f $jobsfile
else
        KEEPALIVEPID=`awk '{print $3}' $jobsfile`

        echo "killing $KEEPALIVEPID"

        kill -9 $KEEPALIVEPID

        echo "No jobs running"

        /bin/rm -f $jobsfile
        echo "Logout complete from $HOST, returning to $RHOST"
        exit 0
fi



Messages sorted by: Reverse Date, Date, Thread, Author