In many versions of the Bourne shell, background processes ( 1.26 ) are automatically killed with a HANGUP signal (signal 1) on logout. But the C shell makes background processes immune to signals and a HANGUP signal at logout doesn't affect the processes; they keep running.
If you want the C shell to work like the Bourne shell, put lines like these in your .logout file ( 3.1 ) :
/tmp ! -z -v eval |
set tf=/tmp/k$$ jobs >$tf if (! -z $tf) then # there are jobs jobs >$tf.1 # rerun it to dump `Done' jobs # skip Stopped jobs (killed by default) grep -v Stopped <$tf.1 >$tf; rm $tf.1 # cannot use a pipe here if (! -z $tf) then # there are running jobs eval `echo kill -1; sed 's/.\([0-9]*\).*/%\1/' <$tf` endif endif rm $tf |
---|
Warning: this may run afoul of various
csh
quirks (
47.2
)
. [To watch this work, put
set
verbose
echo
(
8.17
)
at the top of your
.logout
file. If the logout process clears your screen or closes the window, you can give yourself
n
seconds to read the debugging output by adding
sleep
n
(
40.2
)
to the end of your
.logout
file.
-JP
] The important trick is to run
jobs >file
, not
jobs | command
, as the latter runs
jobs
in a
subshell (
38.4
)
and thus produces no output, although
jobs
|
any-csh-builtin
is good for a laugh
:-)
.
- in comp.unix.questions on Usenet, 5 August 1989