In many versions of the Bourne shell, 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.
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
[To watch this work, put
at the top of your .logout file.
If the logout process clears your screen or closes the window, you can
n seconds to read the debugging output by adding
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
thus produces no output,
good for a laugh
- in comp.unix.questions on Usenet, 5 August 1989