* RE: checking jobs when zsh exits
@ 1999-12-24 15:32 Alan Iwi
1999-12-24 16:48 ` Alan Iwi
0 siblings, 1 reply; 5+ messages in thread
From: Alan Iwi @ 1999-12-24 15:32 UTC (permalink / raw)
To: zsh-users
tjlists@bigfoot.com wrote:
> Also, fyi, the zsh-user@math.gatech.edu address is obsolete...
Okay, thanks. I've got myself onto the list now, so I'll stay subscribed
for at least long enough to catch any replies (longer if I get keen :-)).
> Here's my hack-script, which I call "jobout" and then have:
> alias x='source jobout'
Thanks very much.
Sorry, I'd failed to mention I've already got a hack (some lines in .zshrc)
so that just typing "exit" does approximately the desired thing. I was
just a bit unsure about posting code to the list, but in case it's useful
here it is (see below). It works, but it would be nice to avoid hackiness.
Happy Christmas.
Alan
#----------------------------------------------------------------------
disown_running()
{
# disown running jobs
tmpfile==(:)
jobs -r > $tmpfile
running=`awk '{gsub("[][]","",$1);print "%"$1}' < $tmpfile`
if [ -n "$running" ] ; then disown $running; fi
# check for remaining jobs
jobs >! $tmpfile
[ -z "`<$tmpfile`" ] ; retval=$?
/bin/rm $tmpfile
# returns 1 if jobs still remaining, else 0
return $retval
}
if [ "$PS1" != "" ]
then
exit()
{
disown_running && builtin exit "$@"
echo "You have stopped jobs:"
jobs
select name in 'exit anyway' 'return to prompt'
do
case $name in
'exit anyway')
builtin exit "$@"
;;
'return to prompt')
return
;;
esac
done
}
fi
alias logout='exit'
#----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: checking jobs when zsh exits
1999-12-24 15:32 checking jobs when zsh exits Alan Iwi
@ 1999-12-24 16:48 ` Alan Iwi
0 siblings, 0 replies; 5+ messages in thread
From: Alan Iwi @ 1999-12-24 16:48 UTC (permalink / raw)
To: zsh-users
I am sorry to waste your time by posting wrong code to the list; there is
an error in the .zshrc lines which I just posted. If you intended to use
them, email me and I send you a correct version.
(I was wrongly expecting that doing: variable=`command`
would split the command output according to $IFS and join it up with spaces,
like sh seems to, so that you don't get newlines stored in the variable.)
Alan
^ permalink raw reply [flat|nested] 5+ messages in thread
* checking jobs when zsh exits
@ 1999-12-24 12:48 Alan Iwi
1999-12-24 14:37 ` TjL
1999-12-24 22:09 ` Peter Stephenson
0 siblings, 2 replies; 5+ messages in thread
From: Alan Iwi @ 1999-12-24 12:48 UTC (permalink / raw)
To: zsh-users
During a discussion about zsh on a local newsgroup, someone suggested I
should post this here as a feature request.
When trying to exit from zsh you are warned about running or stopped jobs,
whereas tcsh and bash behaviour is to only warn you about _stopped_ jobs,
not _running_ jobs. I think this distinction is valid, as stopped jobs are
typically likely to be stuff which writes to the terminal (e.g. a gdb
session which you've suspended) whereas running jobs are often X programs
which can carry on fine without the invoking shell (e.g. emacs window).
Rather than having to remember to type stuff like "emacs &!" instead of
"emacs &" every time, would it be possible to add a new option which makes
zsh warn about stopped jobs but not running jobs on exit, like other shells?
Many thanks.
Alan
P.S. I am not on the mailing list myself - I know it's polite to subscribe
to a list before posting to it, but here's what happened when I tried, so
please CC: me any replies - thanks!
... while talking to math.gatech.edu.:
>>> RCPT To:<zsh-users-request@math.gatech.edu>
<<< 550 <zsh-users-request@math.gatech.edu>... User unknown
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: checking jobs when zsh exits
1999-12-24 12:48 Alan Iwi
@ 1999-12-24 14:37 ` TjL
1999-12-24 22:09 ` Peter Stephenson
1 sibling, 0 replies; 5+ messages in thread
From: TjL @ 1999-12-24 14:37 UTC (permalink / raw)
To: Alan Iwi, zsh-users
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@math.gatech.edu 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: checking jobs when zsh exits
1999-12-24 12:48 Alan Iwi
1999-12-24 14:37 ` TjL
@ 1999-12-24 22:09 ` Peter Stephenson
1 sibling, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 1999-12-24 22:09 UTC (permalink / raw)
To: zsh-users
Alan Iwi wrote:
> Rather than having to remember to type stuff like "emacs &!" instead of
> "emacs &" every time, would it be possible to add a new option which makes
> zsh warn about stopped jobs but not running jobs on exit, like other shells?
There was a sort of move to combine this with nohup, which got junked.
However, I don't see why there shouldn't be a check_running_jobs option in
addition to check_jobs.
--
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1999-12-24 22:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-24 15:32 checking jobs when zsh exits Alan Iwi
1999-12-24 16:48 ` Alan Iwi
-- strict thread matches above, loose matches on Subject: below --
1999-12-24 12:48 Alan Iwi
1999-12-24 14:37 ` TjL
1999-12-24 22:09 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).