[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Bash Shell and Running Background Jobs
From: |
Chet Ramey |
Subject: |
RE: Bash Shell and Running Background Jobs |
Date: |
Mon, 22 Sep 2003 09:51:51 -0400 |
> Thanks for the reply. What I'm looking for is behavior similar to
> the korn shell. If there are running background jobs and the user
> tries to exit the shell, they get a warning message that there are
> still running jobs, giving them the opportunity to kill the job(s) or
> continue. If the user then proceeds to exit the shell, the jobs
> continue running.
I could never reproduce this ksh behavior, but I finally figured out
that ksh93 does this only for login shells. Non-login shells behave
as bash does.
If you want to emulate that behavior when login shells terminate, add
something similar to the following to ~/.bash_logout:
_JP=$(jobs -rp)
[ -n "$_JP" ] && {
echo "You have running jobs"
jobs -r
echo -n "kill running jobs? [y/n] "
read ans
case "$ans" in
y*|Y*) kill $_JP 2>/dev/null ;;
*) ;;
esac;
}
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Live...Laugh...Love
Chet Ramey, ITS, CWRU chet@po.cwru.edu http://tiswww.tis.cwru.edu/~chet/